From 5be04ec2ceb1df77afbca4fcbf9e92a712612d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:27:12 +0100 Subject: Sync with the latest Gnulib code (d4ec02b3cc) diff --git a/gl/Makefile.am b/gl/Makefile.am index dcebd4a..df988b3 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -1,6 +1,6 @@ ## DO NOT EDIT! GENERATED AUTOMATICALLY! ## Process this file with automake to produce Makefile.in. -# Copyright (C) 2002-2023 Free Software Foundation, Inc. +# Copyright (C) 2002-2024 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -62,6 +62,7 @@ SUBDIRS = noinst_HEADERS = noinst_LIBRARIES = noinst_LTLIBRARIES = +pkgdata_DATA = EXTRA_DIST = BUILT_SOURCES = SUFFIXES = @@ -350,10 +351,32 @@ if GL_COND_OBJ_ERROR libgnu_a_SOURCES += error.c endif -EXTRA_DIST += error.h - ## end gnulib module error +## begin gnulib module error-h + +BUILT_SOURCES += error.h + +# We need the following in order to override . +error.h: error.in.h $(top_builddir)/config.status $(CXXDEFS_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_ERROR_H''@|$(HAVE_ERROR_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''NEXT_ERROR_H''@|$(NEXT_ERROR_H)|g' \ + -e 's|@''HAVE_ERROR''@|$(HAVE_ERROR)|g' \ + -e 's|@''HAVE_ERROR_AT_LINE''@|$(HAVE_ERROR_AT_LINE)|g' \ + -e 's|@''REPLACE_ERROR''@|$(REPLACE_ERROR)|g' \ + -e 's|@''REPLACE_ERROR_AT_LINE''@|$(REPLACE_ERROR_AT_LINE)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + $(srcdir)/error.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += error.h error.h-t + +EXTRA_DIST += error.in.h + +## end gnulib module error-h + ## begin gnulib module exitfail libgnu_a_SOURCES += exitfail.c @@ -595,6 +618,7 @@ SED_HEADER_STDOUT = sed -e 1h -e '1$(SED_HEADER_NOEDIT)' -e 1G SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t' # Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that +# is its recipe's first line if and only if @NMD@ lines are absent. gl_V_at = $(AM_V_GEN) ## end gnulib module gen-header @@ -698,7 +722,11 @@ EXTRA_DIST += getopt-cdefs.in.h getopt-core.h getopt-ext.h getopt-pfx-core.h get ## begin gnulib module getprogname -libgnu_a_SOURCES += getprogname.h getprogname.c +if GL_COND_OBJ_GETPROGNAME +libgnu_a_SOURCES += getprogname.c +endif + +EXTRA_DIST += getprogname.h ## end gnulib module getprogname @@ -810,6 +838,8 @@ inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \ -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \ -e 's/@''HAVE_IMAXDIV_T''@/$(HAVE_IMAXDIV_T)/g' \ + -e 's/@''REPLACE_IMAXABS''@/$(REPLACE_IMAXABS)/g' \ + -e 's/@''REPLACE_IMAXDIV''@/$(REPLACE_IMAXDIV)/g' \ -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \ -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \ -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \ @@ -827,6 +857,48 @@ EXTRA_DIST += inttypes.in.h ## end gnulib module inttypes-incomplete +## begin gnulib module iswblank + +if GL_COND_OBJ_ISWBLANK +libgnu_a_SOURCES += iswblank.c +endif + +## end gnulib module iswblank + +## begin gnulib module iswctype + +if GL_COND_OBJ_ISWCTYPE +libgnu_a_SOURCES += iswctype.c +endif + +EXTRA_DIST += iswctype-impl.h + +## end gnulib module iswctype + +## begin gnulib module iswdigit + +if GL_COND_OBJ_ISWDIGIT +libgnu_a_SOURCES += iswdigit.c +endif + +## end gnulib module iswdigit + +## begin gnulib module iswpunct + +if GL_COND_OBJ_ISWPUNCT +libgnu_a_SOURCES += iswpunct.c +endif + +## end gnulib module iswpunct + +## begin gnulib module iswxdigit + +if GL_COND_OBJ_ISWXDIGIT +libgnu_a_SOURCES += iswxdigit.c +endif + +## end gnulib module iswxdigit + ## begin gnulib module langinfo BUILT_SOURCES += langinfo.h @@ -917,7 +989,7 @@ locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's/@''GNULIB_SETLOCALE''@/$(GL_GNULIB_SETLOCALE)/g' \ -e 's/@''GNULIB_SETLOCALE_NULL''@/$(GL_GNULIB_SETLOCALE_NULL)/g' \ -e 's/@''GNULIB_DUPLOCALE''@/$(GL_GNULIB_DUPLOCALE)/g' \ - -e 's/@''GNULIB_LOCALENAME''@/$(GL_GNULIB_LOCALENAME)/g' \ + -e 's/@''GNULIB_LOCALENAME_UNSAFE''@/$(GL_GNULIB_LOCALENAME_UNSAFE)/g' \ -e 's|@''HAVE_NEWLOCALE''@|$(HAVE_NEWLOCALE)|g' \ -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \ -e 's|@''HAVE_FREELOCALE''@|$(HAVE_FREELOCALE)|g' \ @@ -1043,11 +1115,15 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_FREXPF''@/$(GL_GNULIB_FREXPF)/g' \ -e 's/@''GNULIB_FREXP''@/$(GL_GNULIB_FREXP)/g' \ -e 's/@''GNULIB_FREXPL''@/$(GL_GNULIB_FREXPL)/g' \ + -e 's/@''GNULIB_GETPAYLOAD''@/$(GL_GNULIB_GETPAYLOAD)/g' \ + -e 's/@''GNULIB_GETPAYLOADF''@/$(GL_GNULIB_GETPAYLOADF)/g' \ + -e 's/@''GNULIB_GETPAYLOADL''@/$(GL_GNULIB_GETPAYLOADL)/g' \ -e 's/@''GNULIB_HYPOT''@/$(GL_GNULIB_HYPOT)/g' \ -e 's/@''GNULIB_HYPOTF''@/$(GL_GNULIB_HYPOTF)/g' \ -e 's/@''GNULIB_HYPOTL''@/$(GL_GNULIB_HYPOTL)/g' \ - < $(srcdir)/math.in.h | \ - sed -e 's/@''GNULIB_ILOGB''@/$(GL_GNULIB_ILOGB)/g' \ + < $(srcdir)/math.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's/@''GNULIB_ILOGB''@/$(GL_GNULIB_ILOGB)/g' \ -e 's/@''GNULIB_ILOGBF''@/$(GL_GNULIB_ILOGBF)/g' \ -e 's/@''GNULIB_ILOGBL''@/$(GL_GNULIB_ILOGBL)/g' \ -e 's/@''GNULIB_ISFINITE''@/$(GL_GNULIB_ISFINITE)/g' \ @@ -1056,6 +1132,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_ISNANF''@/$(GL_GNULIB_ISNANF)/g' \ -e 's/@''GNULIB_ISNAND''@/$(GL_GNULIB_ISNAND)/g' \ -e 's/@''GNULIB_ISNANL''@/$(GL_GNULIB_ISNANL)/g' \ + -e 's/@''GNULIB_LDEXP''@/$(GL_GNULIB_LDEXP)/g' \ -e 's/@''GNULIB_LDEXPF''@/$(GL_GNULIB_LDEXPF)/g' \ -e 's/@''GNULIB_LDEXPL''@/$(GL_GNULIB_LDEXPL)/g' \ -e 's/@''GNULIB_LOG''@/$(GL_GNULIB_LOG)/g' \ @@ -1086,6 +1163,12 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_ROUND''@/$(GL_GNULIB_ROUND)/g' \ -e 's/@''GNULIB_ROUNDF''@/$(GL_GNULIB_ROUNDF)/g' \ -e 's/@''GNULIB_ROUNDL''@/$(GL_GNULIB_ROUNDL)/g' \ + -e 's/@''GNULIB_SETPAYLOAD''@/$(GL_GNULIB_SETPAYLOAD)/g' \ + -e 's/@''GNULIB_SETPAYLOADF''@/$(GL_GNULIB_SETPAYLOADF)/g' \ + -e 's/@''GNULIB_SETPAYLOADL''@/$(GL_GNULIB_SETPAYLOADL)/g' \ + -e 's/@''GNULIB_SETPAYLOADSIG''@/$(GL_GNULIB_SETPAYLOADSIG)/g' \ + -e 's/@''GNULIB_SETPAYLOADSIGF''@/$(GL_GNULIB_SETPAYLOADSIGF)/g' \ + -e 's/@''GNULIB_SETPAYLOADSIGL''@/$(GL_GNULIB_SETPAYLOADSIGL)/g' \ -e 's/@''GNULIB_SIGNBIT''@/$(GL_GNULIB_SIGNBIT)/g' \ -e 's/@''GNULIB_SINF''@/$(GL_GNULIB_SINF)/g' \ -e 's/@''GNULIB_SINL''@/$(GL_GNULIB_SINL)/g' \ @@ -1098,14 +1181,21 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_TRUNC''@/$(GL_GNULIB_TRUNC)/g' \ -e 's/@''GNULIB_TRUNCF''@/$(GL_GNULIB_TRUNCF)/g' \ -e 's/@''GNULIB_TRUNCL''@/$(GL_GNULIB_TRUNCL)/g' \ + -e 's/@''GNULIB_TOTALORDER''@/$(GL_GNULIB_TOTALORDER)/g' \ + -e 's/@''GNULIB_TOTALORDERF''@/$(GL_GNULIB_TOTALORDERF)/g' \ + -e 's/@''GNULIB_TOTALORDERL''@/$(GL_GNULIB_TOTALORDERL)/g' \ + -e 's/@''GNULIB_TOTALORDERMAG''@/$(GL_GNULIB_TOTALORDERMAG)/g' \ + -e 's/@''GNULIB_TOTALORDERMAGF''@/$(GL_GNULIB_TOTALORDERMAGF)/g' \ + -e 's/@''GNULIB_TOTALORDERMAGL''@/$(GL_GNULIB_TOTALORDERMAGL)/g' \ -e 's/@''GNULIB_MDA_J0''@/$(GL_GNULIB_MDA_J0)/g' \ -e 's/@''GNULIB_MDA_J1''@/$(GL_GNULIB_MDA_J1)/g' \ -e 's/@''GNULIB_MDA_JN''@/$(GL_GNULIB_MDA_JN)/g' \ -e 's/@''GNULIB_MDA_Y0''@/$(GL_GNULIB_MDA_Y0)/g' \ -e 's/@''GNULIB_MDA_Y1''@/$(GL_GNULIB_MDA_Y1)/g' \ -e 's/@''GNULIB_MDA_YN''@/$(GL_GNULIB_MDA_YN)/g' \ - | \ - sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \ -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \ -e 's|@''HAVE_ASINF''@|$(HAVE_ASINF)|g' \ -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \ @@ -1132,6 +1222,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \ -e 's|@''HAVE_FMODL''@|$(HAVE_FMODL)|g' \ -e 's|@''HAVE_FREXPF''@|$(HAVE_FREXPF)|g' \ + -e 's|@''HAVE_GETPAYLOAD''@|$(HAVE_GETPAYLOAD)|g' \ + -e 's|@''HAVE_GETPAYLOADF''@|$(HAVE_GETPAYLOADF)|g' \ + -e 's|@''HAVE_GETPAYLOADL''@|$(HAVE_GETPAYLOADL)|g' \ -e 's|@''HAVE_HYPOTF''@|$(HAVE_HYPOTF)|g' \ -e 's|@''HAVE_HYPOTL''@|$(HAVE_HYPOTL)|g' \ -e 's|@''HAVE_ILOGB''@|$(HAVE_ILOGB)|g' \ @@ -1157,6 +1250,12 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \ -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \ -e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \ + -e 's|@''HAVE_SETPAYLOAD''@|$(HAVE_SETPAYLOAD)|g' \ + -e 's|@''HAVE_SETPAYLOADF''@|$(HAVE_SETPAYLOADF)|g' \ + -e 's|@''HAVE_SETPAYLOADL''@|$(HAVE_SETPAYLOADL)|g' \ + -e 's|@''HAVE_SETPAYLOADSIG''@|$(HAVE_SETPAYLOADSIG)|g' \ + -e 's|@''HAVE_SETPAYLOADSIGF''@|$(HAVE_SETPAYLOADSIGF)|g' \ + -e 's|@''HAVE_SETPAYLOADSIGL''@|$(HAVE_SETPAYLOADSIGL)|g' \ -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \ -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ -e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \ @@ -1165,6 +1264,14 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \ -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \ -e 's|@''HAVE_TANHF''@|$(HAVE_TANHF)|g' \ + -e 's|@''HAVE_TOTALORDER''@|$(HAVE_TOTALORDER)|g' \ + -e 's|@''HAVE_TOTALORDERF''@|$(HAVE_TOTALORDERF)|g' \ + -e 's|@''HAVE_TOTALORDERL''@|$(HAVE_TOTALORDERL)|g' \ + -e 's|@''HAVE_TOTALORDERMAG''@|$(HAVE_TOTALORDERMAG)|g' \ + -e 's|@''HAVE_TOTALORDERMAGF''@|$(HAVE_TOTALORDERMAGF)|g' \ + -e 's|@''HAVE_TOTALORDERMAGL''@|$(HAVE_TOTALORDERMAGL)|g' \ + < $@-t2 > $@-t3 + $(AM_V_at)sed \ -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ @@ -1201,8 +1308,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ - | \ - sed -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \ + < $@-t3 > $@-t4 + $(AM_V_at)sed \ + -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \ -e 's|@''REPLACE_ASINF''@|$(REPLACE_ASINF)|g' \ -e 's|@''REPLACE_ATANF''@|$(REPLACE_ATANF)|g' \ -e 's|@''REPLACE_ATAN2F''@|$(REPLACE_ATAN2F)|g' \ @@ -1233,6 +1341,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_FREXPF''@|$(REPLACE_FREXPF)|g' \ -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ + -e 's|@''REPLACE_GETPAYLOAD''@|$(REPLACE_GETPAYLOAD)|g' \ + -e 's|@''REPLACE_GETPAYLOADF''@|$(REPLACE_GETPAYLOADF)|g' \ + -e 's|@''REPLACE_GETPAYLOADL''@|$(REPLACE_GETPAYLOADL)|g' \ -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \ -e 's|@''REPLACE_HYPOT''@|$(REPLACE_HYPOT)|g' \ -e 's|@''REPLACE_HYPOTF''@|$(REPLACE_HYPOTF)|g' \ @@ -1244,6 +1355,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \ -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \ -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ + < $@-t4 > $@-t5 + $(AM_V_at)sed \ + -e 's|@''REPLACE_LDEXP''@|$(REPLACE_LDEXP)|g' \ -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ -e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \ -e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \ @@ -1279,15 +1393,22 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \ -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \ -e 's|@''REPLACE_TANHF''@|$(REPLACE_TANHF)|g' \ + -e 's|@''REPLACE_TOTALORDER''@|$(REPLACE_TOTALORDER)|g' \ + -e 's|@''REPLACE_TOTALORDERF''@|$(REPLACE_TOTALORDERF)|g' \ + -e 's|@''REPLACE_TOTALORDERL''@|$(REPLACE_TOTALORDERL)|g' \ + -e 's|@''REPLACE_TOTALORDERMAG''@|$(REPLACE_TOTALORDERMAG)|g' \ + -e 's|@''REPLACE_TOTALORDERMAGF''@|$(REPLACE_TOTALORDERMAGF)|g' \ + -e 's|@''REPLACE_TOTALORDERMAGL''@|$(REPLACE_TOTALORDERMAGL)|g' \ -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \ -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \ -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - > $@-t - $(AM_V_at)mv $@-t $@ -MOSTLYCLEANFILES += math.h math.h-t + < $@-t5 > $@-t6 + $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3 $@-t4 $@-t5 + $(AM_V_at)mv $@-t6 $@ +MOSTLYCLEANFILES += math.h math.h-t1 math.h-t2 math.h-t3 math.h-t4 math.h-t5 math.h-t6 EXTRA_DIST += math.in.h @@ -1313,6 +1434,12 @@ endif ## end gnulib module mbsinit +## begin gnulib module mbszero + +libgnu_a_SOURCES += mbszero.c + +## end gnulib module mbszero + ## begin gnulib module mbtowc if GL_COND_OBJ_MBTOWC @@ -1534,6 +1661,14 @@ EXTRA_DIST += setlocale_null.h windows-initguard.h ## end gnulib module setlocale-null +## begin gnulib module setlocale-null-unlocked + +libgnu_a_SOURCES += setlocale_null-unlocked.c + +EXTRA_DIST += setlocale_null.h + +## end gnulib module setlocale-null-unlocked + ## begin gnulib module size_max libgnu_a_SOURCES += size_max.h @@ -1625,26 +1760,6 @@ EXTRA_DIST += stat-time.h ## end gnulib module stat-time -## begin gnulib module stdalign - -BUILT_SOURCES += $(STDALIGN_H) - -# We need the following in order to create when the system -# doesn't have one that works. -if GL_GENERATE_STDALIGN_H -stdalign.h: stdalign.in.h $(top_builddir)/config.status - $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/stdalign.in.h - $(AM_V_at)mv $@-t $@ -else -stdalign.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stdalign.h stdalign.h-t - -EXTRA_DIST += stdalign.in.h - -## end gnulib module stdalign - ## begin gnulib module stdckdint BUILT_SOURCES += $(STDCKDINT_H) @@ -1816,14 +1931,17 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) -e 's/@''GNULIB_MDA_GETW''@/$(GL_GNULIB_MDA_GETW)/g' \ -e 's/@''GNULIB_MDA_PUTW''@/$(GL_GNULIB_MDA_PUTW)/g' \ -e 's/@''GNULIB_MDA_TEMPNAM''@/$(GL_GNULIB_MDA_TEMPNAM)/g' \ - < $(srcdir)/stdio.in.h | \ - sed -e 's|@''HAVE_DECL_FCLOSEALL''@|$(HAVE_DECL_FCLOSEALL)|g' \ + < $(srcdir)/stdio.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's|@''HAVE_DECL_FCLOSEALL''@|$(HAVE_DECL_FCLOSEALL)|g' \ -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \ -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ + -e 's|@''HAVE_DECL_GETW''@|$(HAVE_DECL_GETW)|g' \ -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ + -e 's|@''HAVE_DECL_PUTW''@|$(HAVE_DECL_PUTW)|g' \ -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ @@ -1834,6 +1952,8 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ @@ -1871,9 +1991,10 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - > $@-t - $(AM_V_at)mv $@-t $@ -MOSTLYCLEANFILES += stdio.h stdio.h-t + < $@-t2 > $@-t3 + $(AM_V_at)rm -f $@-t1 $@-t2 + $(AM_V_at)mv $@-t3 $@ +MOSTLYCLEANFILES += stdio.h stdio.h-t1 stdio.h-t2 stdio.h-t3 if GL_COND_OBJ_STDIO_READ libgnu_a_SOURCES += stdio-read.c @@ -1908,10 +2029,12 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GL_GNULIB_CANONICALIZE_FILE_NAME)/g' \ -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \ -e 's/@''GNULIB_GETLOADAVG''@/$(GL_GNULIB_GETLOADAVG)/g' \ + -e 's/@''GNULIB_GETPROGNAME''@/$(GL_GNULIB_GETPROGNAME)/g' \ -e 's/@''GNULIB_GETSUBOPT''@/$(GL_GNULIB_GETSUBOPT)/g' \ -e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \ -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \ -e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \ + -e 's/@''GNULIB_MBSTOWCS''@/$(GL_GNULIB_MBSTOWCS)/g' \ -e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \ -e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \ -e 's/@''GNULIB_MKOSTEMP''@/$(GL_GNULIB_MKOSTEMP)/g' \ @@ -1924,6 +2047,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's/@''GNULIB_PTSNAME_R''@/$(GL_GNULIB_PTSNAME_R)/g' \ -e 's/@''GNULIB_PUTENV''@/$(GL_GNULIB_PUTENV)/g' \ -e 's/@''GNULIB_QSORT_R''@/$(GL_GNULIB_QSORT_R)/g' \ + -e 's/@''GNULIB_RAND''@/$(GL_GNULIB_RAND)/g' \ -e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \ -e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \ -e 's/@''GNULIB_REALLOC_GNU''@/$(GL_GNULIB_REALLOC_GNU)/g' \ @@ -1934,6 +2058,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's/@''GNULIB_SECURE_GETENV''@/$(GL_GNULIB_SECURE_GETENV)/g' \ -e 's/@''GNULIB_SETENV''@/$(GL_GNULIB_SETENV)/g' \ -e 's/@''GNULIB_STRTOD''@/$(GL_GNULIB_STRTOD)/g' \ + -e 's/@''GNULIB_STRTOF''@/$(GL_GNULIB_STRTOF)/g' \ -e 's/@''GNULIB_STRTOL''@/$(GL_GNULIB_STRTOL)/g' \ -e 's/@''GNULIB_STRTOLD''@/$(GL_GNULIB_STRTOLD)/g' \ -e 's/@''GNULIB_STRTOLL''@/$(GL_GNULIB_STRTOLL)/g' \ @@ -1948,8 +2073,9 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's/@''GNULIB_MDA_GCVT''@/$(GL_GNULIB_MDA_GCVT)/g' \ -e 's/@''GNULIB_MDA_MKTEMP''@/$(GL_GNULIB_MDA_MKTEMP)/g' \ -e 's/@''GNULIB_MDA_PUTENV''@/$(GL_GNULIB_MDA_PUTENV)/g' \ - < $(srcdir)/stdlib.in.h | \ - sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ + < $(srcdir)/stdlib.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ -e 's|@''HAVE_ALIGNED_ALLOC''@|$(HAVE_ALIGNED_ALLOC)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ @@ -1957,6 +2083,8 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \ -e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ + -e 's|@''HAVE_DECL_PROGRAM_INVOCATION_NAME''@|$(HAVE_DECL_PROGRAM_INVOCATION_NAME)|g' \ + -e 's|@''HAVE_GETPROGNAME''@|$(HAVE_GETPROGNAME)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ -e 's|@''HAVE_INITSTATE''@|$(HAVE_INITSTATE)|g' \ @@ -1983,6 +2111,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''HAVE_SETSTATE''@|$(HAVE_SETSTATE)|g' \ -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \ -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ + -e 's|@''HAVE_STRTOF''@|$(HAVE_STRTOF)|g' \ -e 's|@''HAVE_STRTOL''@|$(HAVE_STRTOL)|g' \ -e 's|@''HAVE_STRTOLD''@|$(HAVE_STRTOLD)|g' \ -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ @@ -1992,21 +2121,33 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''REPLACE__EXIT''@|$(REPLACE__EXIT)|g' \ -e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \ -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \ -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ + -e 's|@''REPLACE_GETLOADAVG''@|$(REPLACE_GETLOADAVG)|g' \ + -e 's|@''REPLACE_GETPROGNAME''@|$(REPLACE_GETPROGNAME)|g' \ + -e 's|@''REPLACE_GETSUBOPT''@|$(REPLACE_GETSUBOPT)|g' \ -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \ -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \ -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \ + -e 's|@''REPLACE_MB_CUR_MAX''@|$(REPLACE_MB_CUR_MAX)|g' \ + -e 's|@''REPLACE_MBSTOWCS''@|$(REPLACE_MBSTOWCS)|g' \ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ + -e 's|@''REPLACE_MKOSTEMP''@|$(REPLACE_MKOSTEMP)|g' \ + -e 's|@''REPLACE_MKOSTEMPS''@|$(REPLACE_MKOSTEMPS)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ -e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \ + -e 's|@''REPLACE_POSIX_OPENPT''@|$(REPLACE_POSIX_OPENPT)|g' \ -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \ + -e 's|@''REPLACE_RAND''@|$(REPLACE_RAND)|g' \ -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ -e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \ @@ -2016,6 +2157,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ -e 's|@''REPLACE_SETSTATE''@|$(REPLACE_SETSTATE)|g' \ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ + -e 's|@''REPLACE_STRTOF''@|$(REPLACE_STRTOF)|g' \ -e 's|@''REPLACE_STRTOL''@|$(REPLACE_STRTOL)|g' \ -e 's|@''REPLACE_STRTOLD''@|$(REPLACE_STRTOLD)|g' \ -e 's|@''REPLACE_STRTOLL''@|$(REPLACE_STRTOLL)|g' \ @@ -2027,9 +2169,10 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e '/definition of _Noreturn/r $(_NORETURN_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - > $@-t - $(AM_V_at)mv $@-t $@ -MOSTLYCLEANFILES += stdlib.h stdlib.h-t + < $@-t2 > $@-t3 + $(AM_V_at)rm -f $@-t1 $@-t2 + $(AM_V_at)mv $@-t3 $@ +MOSTLYCLEANFILES += stdlib.h stdlib.h-t1 stdlib.h-t2 stdlib.h-t3 EXTRA_DIST += stdlib.in.h @@ -2147,8 +2290,9 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's/@''GNULIB_MDA_MEMCCPY''@/$(GL_GNULIB_MDA_MEMCCPY)/g' \ -e 's/@''GNULIB_MDA_STRDUP''@/$(GL_GNULIB_MDA_STRDUP)/g' \ -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \ - < $(srcdir)/string.in.h | \ - sed -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \ + < $(srcdir)/string.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \ -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ @@ -2176,7 +2320,10 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \ -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ + -e 's|@''REPLACE_MEMPCPY''@|$(REPLACE_MEMPCPY)|g' \ + -e 's|@''REPLACE_MEMSET_EXPLICIT''@|$(REPLACE_MEMSET_EXPLICIT)|g' \ -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ + -e 's|@''REPLACE_STPCPY''@|$(REPLACE_STPCPY)|g' \ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ @@ -2190,13 +2337,15 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ -e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ + -e 's|@''REPLACE_STRVERSCMP''@|$(REPLACE_STRVERSCMP)|g' \ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - > $@-t - $(AM_V_at)mv $@-t $@ -MOSTLYCLEANFILES += string.h string.h-t + < $@-t1 > $@-t2 + $(AM_V_at)rm -f $@-t1 + $(AM_V_at)mv $@-t2 $@ +MOSTLYCLEANFILES += string.h string.h-t1 string.h-t2 EXTRA_DIST += string.in.h @@ -2425,7 +2574,7 @@ libgnu_a_SOURCES += glthread/threadlib.c ## end gnulib module threadlib -## begin gnulib module time +## begin gnulib module time-h BUILT_SOURCES += time.h @@ -2444,6 +2593,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_NANOSLEEP''@/$(GL_GNULIB_NANOSLEEP)/g' \ -e 's/@''GNULIB_STRFTIME''@/$(GL_GNULIB_STRFTIME)/g' \ -e 's/@''GNULIB_STRPTIME''@/$(GL_GNULIB_STRPTIME)/g' \ + -e 's/@''GNULIB_TIME''@/$(GL_GNULIB_TIME)/g' \ -e 's/@''GNULIB_TIMEGM''@/$(GL_GNULIB_TIMEGM)/g' \ -e 's/@''GNULIB_TIMESPEC_GET''@/$(GL_GNULIB_TIMESPEC_GET)/g' \ -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GL_GNULIB_TIMESPEC_GETRES)/g' \ @@ -2465,7 +2615,10 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \ + -e 's|@''REPLACE_TIME''@|$(REPLACE_TIME)|g' \ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ + -e 's|@''REPLACE_TIMESPEC_GET''@|$(REPLACE_TIMESPEC_GET)|g' \ + -e 's|@''REPLACE_TIMESPEC_GETRES''@|$(REPLACE_TIMESPEC_GETRES)|g' \ -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \ -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ @@ -2481,7 +2634,7 @@ MOSTLYCLEANFILES += time.h time.h-t EXTRA_DIST += time.in.h -## end gnulib module time +## end gnulib module time-h ## begin gnulib module time_r @@ -2540,6 +2693,8 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's/@''GNULIB_FDATASYNC''@/$(GL_GNULIB_FDATASYNC)/g' \ -e 's/@''GNULIB_FSYNC''@/$(GL_GNULIB_FSYNC)/g' \ -e 's/@''GNULIB_FTRUNCATE''@/$(GL_GNULIB_FTRUNCATE)/g' \ + < $(srcdir)/unistd.in.h > $@-t1 + $(AM_V_at)sed \ -e 's/@''GNULIB_GETCWD''@/$(GL_GNULIB_GETCWD)/g' \ -e 's/@''GNULIB_GETDOMAINNAME''@/$(GL_GNULIB_GETDOMAINNAME)/g' \ -e 's/@''GNULIB_GETDTABLESIZE''@/$(GL_GNULIB_GETDTABLESIZE)/g' \ @@ -2601,8 +2756,9 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's/@''GNULIB_MDA_SWAB''@/$(GL_GNULIB_MDA_SWAB)/g' \ -e 's/@''GNULIB_MDA_UNLINK''@/$(GL_GNULIB_MDA_UNLINK)/g' \ -e 's/@''GNULIB_MDA_WRITE''@/$(GL_GNULIB_MDA_WRITE)/g' \ - < $(srcdir)/unistd.in.h | \ - sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ -e 's|@''HAVE_COPY_FILE_RANGE''@|$(HAVE_COPY_FILE_RANGE)|g' \ -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ @@ -2649,13 +2805,15 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ - | \ - sed -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \ + < $@-t2 > $@-t3 + $(AM_V_at)sed \ + -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \ -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \ -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ + -e 's|@''REPLACE_DUP3''@|$(REPLACE_DUP3)|g' \ -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \ -e 's|@''REPLACE_EXECLE''@|$(REPLACE_EXECLE)|g' \ -e 's|@''REPLACE_EXECLP''@|$(REPLACE_EXECLP)|g' \ @@ -2664,11 +2822,14 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_EXECVP''@|$(REPLACE_EXECVP)|g' \ -e 's|@''REPLACE_EXECVPE''@|$(REPLACE_EXECVPE)|g' \ -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \ + -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ + -e 's|@''REPLACE_FDATASYNC''@|$(REPLACE_FDATASYNC)|g' \ -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \ + -e 's|@''REPLACE_GETENTROPY''@|$(REPLACE_GETENTROPY)|g' \ -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ @@ -2679,12 +2840,14 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ + -e 's|@''REPLACE_PIPE2''@|$(REPLACE_PIPE2)|g' \ -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \ -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ + -e 's|@''REPLACE_SETHOSTNAME''@|$(REPLACE_SETHOSTNAME)|g' \ -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \ @@ -2700,9 +2863,10 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - > $@-t - $(AM_V_at)mv $@-t $@ -MOSTLYCLEANFILES += unistd.h unistd.h-t + < $@-t3 > $@-t4 + $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3 + $(AM_V_at)mv $@-t4 $@ +MOSTLYCLEANFILES += unistd.h unistd.h-t1 unistd.h-t2 unistd.h-t3 unistd.h-t4 EXTRA_DIST += unistd.in.h @@ -2777,6 +2941,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) -e 's/@''GNULIB_BTOWC''@/$(GL_GNULIB_BTOWC)/g' \ -e 's/@''GNULIB_WCTOB''@/$(GL_GNULIB_WCTOB)/g' \ -e 's/@''GNULIB_MBSINIT''@/$(GL_GNULIB_MBSINIT)/g' \ + -e 's/@''GNULIB_MBSZERO''@/$(GL_GNULIB_MBSZERO)/g' \ -e 's/@''GNULIB_MBRTOWC''@/$(GL_GNULIB_MBRTOWC)/g' \ -e 's/@''GNULIB_MBRLEN''@/$(GL_GNULIB_MBRLEN)/g' \ -e 's/@''GNULIB_MBSRTOWCS''@/$(GL_GNULIB_MBSRTOWCS)/g' \ @@ -2815,10 +2980,12 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) -e 's/@''GNULIB_WCSTOK''@/$(GL_GNULIB_WCSTOK)/g' \ -e 's/@''GNULIB_WCSWIDTH''@/$(GL_GNULIB_WCSWIDTH)/g' \ -e 's/@''GNULIB_WCSFTIME''@/$(GL_GNULIB_WCSFTIME)/g' \ + -e 's/@''GNULIB_WGETCWD''@/$(GL_GNULIB_WGETCWD)/g' \ -e 's/@''GNULIB_MDA_WCSDUP''@/$(GL_GNULIB_MDA_WCSDUP)/g' \ -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \ - < $(srcdir)/wchar.in.h | \ - sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ + < $(srcdir)/wchar.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \ @@ -2861,8 +3028,9 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ -e 's|@''HAVE_DECL_WCSDUP''@|$(HAVE_DECL_WCSDUP)|g' \ -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ - | \ - sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \ -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ @@ -2877,13 +3045,19 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \ -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \ + -e 's|@''REPLACE_WCSCMP''@|$(REPLACE_WCSCMP)|g' \ + -e 's|@''REPLACE_WCSNCMP''@|$(REPLACE_WCSNCMP)|g' \ + -e 's|@''REPLACE_WCSSTR''@|$(REPLACE_WCSSTR)|g' \ -e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|g' \ + -e 's|@''REPLACE_WMEMCMP''@|$(REPLACE_WMEMCMP)|g' \ + -e 's|@''REPLACE_WMEMPCPY''@|$(REPLACE_WMEMPCPY)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - > $@-t - $(AM_V_at)mv $@-t $@ -MOSTLYCLEANFILES += wchar.h wchar.h-t + < $@-t2 > $@-t3 + $(AM_V_at)rm -f $@-t1 $@-t2 + $(AM_V_at)mv $@-t3 $@ +MOSTLYCLEANFILES += wchar.h wchar.h-t1 wchar.h-t2 wchar.h-t3 EXTRA_DIST += wchar.in.h @@ -2897,6 +3071,16 @@ endif ## end gnulib module wcrtomb +## begin gnulib module wctype + +if GL_COND_OBJ_WCTYPE +libgnu_a_SOURCES += wctype.c +endif + +EXTRA_DIST += wctype-impl.h + +## end gnulib module wctype + ## begin gnulib module wctype-h BUILT_SOURCES += wctype.h @@ -2904,7 +3088,7 @@ libgnu_a_SOURCES += wctype-h.c # We need the following in order to create when the system # doesn't have one that works with the given compiler. -wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) +wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(gl_V_at)$(SED_HEADER_STDOUT) \ -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ @@ -2916,6 +3100,7 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \ -e 's/@''GNULIB_ISWBLANK''@/$(GL_GNULIB_ISWBLANK)/g' \ -e 's/@''GNULIB_ISWDIGIT''@/$(GL_GNULIB_ISWDIGIT)/g' \ + -e 's/@''GNULIB_ISWPUNCT''@/$(GL_GNULIB_ISWPUNCT)/g' \ -e 's/@''GNULIB_ISWXDIGIT''@/$(GL_GNULIB_ISWXDIGIT)/g' \ -e 's/@''GNULIB_WCTYPE''@/$(GL_GNULIB_WCTYPE)/g' \ -e 's/@''GNULIB_ISWCTYPE''@/$(GL_GNULIB_ISWCTYPE)/g' \ @@ -2928,10 +3113,14 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \ -e 's/@''REPLACE_ISWDIGIT''@/$(REPLACE_ISWDIGIT)/g' \ + -e 's/@''REPLACE_ISWPUNCT''@/$(REPLACE_ISWPUNCT)/g' \ -e 's/@''REPLACE_ISWXDIGIT''@/$(REPLACE_ISWXDIGIT)/g' \ -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \ + -e 's/@''REPLACE_WCTRANS''@/$(REPLACE_WCTRANS)/g' \ + -e 's/@''REPLACE_WCTYPE''@/$(REPLACE_WCTYPE)/g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ $(srcdir)/wctype.in.h > $@-t $(AM_V_at)mv $@-t $@ diff --git a/gl/_Noreturn.h b/gl/_Noreturn.h index 6ecea98..7326bd4 100644 --- a/gl/_Noreturn.h +++ b/gl/_Noreturn.h @@ -1,5 +1,5 @@ /* A C macro for declaring that a function does not return. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published diff --git a/gl/af_alg.c b/gl/af_alg.c index 9f022ce..6fd08c2 100644 --- a/gl/af_alg.c +++ b/gl/af_alg.c @@ -1,5 +1,5 @@ /* af_alg.c - Compute message digests from file streams and buffers. - Copyright (C) 2018-2023 Free Software Foundation, Inc. + Copyright (C) 2018-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/af_alg.h b/gl/af_alg.h index e8ffb3f..ed933e1 100644 --- a/gl/af_alg.h +++ b/gl/af_alg.h @@ -1,5 +1,5 @@ /* af_alg.h - Compute message digests from file streams and buffers. - Copyright (C) 2018-2023 Free Software Foundation, Inc. + Copyright (C) 2018-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/alloca.in.h b/gl/alloca.in.h index a1bb3d7..6aa47df 100644 --- a/gl/alloca.in.h +++ b/gl/alloca.in.h @@ -1,6 +1,6 @@ /* Memory allocation on the stack. - Copyright (C) 1995, 1999, 2001-2004, 2006-2023 Free Software Foundation, + Copyright (C) 1995, 1999, 2001-2004, 2006-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify diff --git a/gl/arg-nonnull.h b/gl/arg-nonnull.h index 9498ae1..46c711c 100644 --- a/gl/arg-nonnull.h +++ b/gl/arg-nonnull.h @@ -1,5 +1,5 @@ /* A C macro for declaring that specific arguments must not be NULL. - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h index 80e6713..523a448 100644 --- a/gl/arpa_inet.in.h +++ b/gl/arpa_inet.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -49,6 +49,11 @@ #ifndef _@GUARD_PREFIX@_ARPA_INET_H #define _@GUARD_PREFIX@_ARPA_INET_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Get all possible declarations of inet_ntop() and inet_pton(). */ #if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \ && @HAVE_WS2TCPIP_H@ diff --git a/gl/asnprintf.c b/gl/asnprintf.c index f4861bf..a6c09bc 100644 --- a/gl/asnprintf.c +++ b/gl/asnprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/asprintf.c b/gl/asprintf.c index ba58e06..b0c3347 100644 --- a/gl/asprintf.c +++ b/gl/asprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007, 2009-2023 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify diff --git a/gl/assert.in.h b/gl/assert.in.h index b0ab99c..6e4995e 100644 --- a/gl/assert.in.h +++ b/gl/assert.in.h @@ -1,5 +1,5 @@ /* Substitute for and wrapper around - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/attribute.h b/gl/attribute.h index 130644d..710341b 100644 --- a/gl/attribute.h +++ b/gl/attribute.h @@ -1,6 +1,6 @@ /* ATTRIBUTE_* macros for using attributes in GCC and similar compilers - Copyright 2020-2023 Free Software Foundation, Inc. + Copyright 2020-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -41,6 +41,21 @@ These names begin with 'ATTRIBUTE_' to avoid name clashes. */ +/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_ALWAYS_INLINE, + _GL_ATTRIBUTE_ARTIFICIAL, _GL_ATTRIBUTE_COLD, _GL_ATTRIBUTE_CONST, + _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR, + _GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE, + _GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_LEAF, + _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_MAY_ALIAS, _GL_ATTRIBUTE_MAYBE_UNUSED, + _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE, _GL_ATTRIBUTE_NONNULL, + _GL_ATTRIBUTE_NONSTRING, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, + _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_RETURNS_NONNULL, + _GL_ATTRIBUTE_SENTINEL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + + /* =============== Attributes for specific kinds of functions =============== */ /* Attributes for functions that should not be used. */ @@ -167,6 +182,8 @@ /* The function does not throw exceptions. */ /* Applies to: functions. */ +/* After a function's parameter list, this attribute must come first, before + other attributes. */ #define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW /* Do not inline the function. */ diff --git a/gl/base64.c b/gl/base64.c index 95b669a..c8b3b76 100644 --- a/gl/base64.c +++ b/gl/base64.c @@ -1,5 +1,5 @@ /* base64.c -- Encode binary data using printable characters. - Copyright (C) 1999-2001, 2004-2006, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 1999-2001, 2004-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -42,6 +42,7 @@ #include /* Get prototype. */ +#define BASE64_INLINE _GL_EXTERN_INLINE #include "base64.h" /* Get imalloc. */ @@ -49,9 +50,6 @@ #include -/* Get UCHAR_MAX. */ -#include - #include /* Convert 'char' to 'unsigned char' without casting. */ @@ -242,7 +240,7 @@ base64_encode_alloc (const char *in, idx_t inlen, char **out) : (_) == '/' ? 63 \ : -1) -static const signed char b64[0x100] = { +signed char const base64_to_int[256] = { B64 (0), B64 (1), B64 (2), B64 (3), B64 (4), B64 (5), B64 (6), B64 (7), B64 (8), B64 (9), B64 (10), B64 (11), @@ -309,28 +307,6 @@ static const signed char b64[0x100] = { B64 (252), B64 (253), B64 (254), B64 (255) }; -#if UCHAR_MAX == 255 -# define uchar_in_range(c) true -#else -# define uchar_in_range(c) ((c) <= 255) -#endif - -/* Return true if CH is a character from the Base64 alphabet, and - false otherwise. Note that '=' is padding and not considered to be - part of the alphabet. */ -bool -isbase64 (char ch) -{ - return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)]; -} - -/* Initialize decode-context buffer, CTX. */ -void -base64_decode_ctx_init (struct base64_decode_context *ctx) -{ - ctx->i = 0; -} - /* If CTX->i is 0 or 4, there are four or more bytes in [*IN..IN_END), and none of those four is a newline, then return *IN. Otherwise, copy up to 4 - CTX->i non-newline bytes from that range into CTX->buf, starting at @@ -405,8 +381,8 @@ decode_4 (char const *restrict in, idx_t inlen, if (*outleft) { - *out++ = ((b64[to_uchar (in[0])] << 2) - | (b64[to_uchar (in[1])] >> 4)); + *out++ = ((base64_to_int[to_uchar (in[0])] << 2) + | (base64_to_int[to_uchar (in[1])] >> 4)); --*outleft; } @@ -420,6 +396,10 @@ decode_4 (char const *restrict in, idx_t inlen, if (in[3] != '=') return_false; + + /* Reject non-canonical encodings. */ + if (base64_to_int[to_uchar (in[1])] & 0x0f) + return_false; } else { @@ -428,8 +408,8 @@ decode_4 (char const *restrict in, idx_t inlen, if (*outleft) { - *out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0) - | (b64[to_uchar (in[2])] >> 2)); + *out++ = (((base64_to_int[to_uchar (in[1])] << 4) & 0xf0) + | (base64_to_int[to_uchar (in[2])] >> 2)); --*outleft; } @@ -440,6 +420,10 @@ decode_4 (char const *restrict in, idx_t inlen, { if (inlen != 4) return_false; + + /* Reject non-canonical encodings. */ + if (base64_to_int[to_uchar (in[2])] & 0x03) + return_false; } else { @@ -448,8 +432,8 @@ decode_4 (char const *restrict in, idx_t inlen, if (*outleft) { - *out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0) - | b64[to_uchar (in[3])]); + *out++ = (((base64_to_int[to_uchar (in[2])] << 6) & 0xc0) + | base64_to_int[to_uchar (in[3])]); --*outleft; } } diff --git a/gl/base64.h b/gl/base64.h index 9913765..7691f6c 100644 --- a/gl/base64.h +++ b/gl/base64.h @@ -1,5 +1,5 @@ /* base64.h -- Encode binary data using printable characters. - Copyright (C) 2004-2006, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2004-2006, 2009-2024 Free Software Foundation, Inc. Written by Simon Josefsson. This file is free software: you can redistribute it and/or modify @@ -16,18 +16,33 @@ along with this program. If not, see . */ #ifndef BASE64_H -# define BASE64_H +#define BASE64_H + +/* This file uses _GL_INLINE_HEADER_BEGIN. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif /* Get idx_t. */ -# include +#include + +/* Pacify GCC in isubase64. */ +#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif + +_GL_INLINE_HEADER_BEGIN +#ifndef BASE64_INLINE +# define BASE64_INLINE _GL_INLINE +#endif -# ifdef __cplusplus +#ifdef __cplusplus extern "C" { -# endif +#endif /* This uses that the expression (n+(k-1))/k means the smallest integer >= n/k, i.e., the ceiling of n/k. */ -# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4) +#define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4) struct base64_decode_context { @@ -35,14 +50,31 @@ struct base64_decode_context char buf[4]; }; -extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST; +extern signed char const base64_to_int[256]; + +BASE64_INLINE bool +isubase64 (unsigned char ch) +{ + return ch < sizeof base64_to_int && 0 <= base64_to_int[ch]; +} + +BASE64_INLINE bool +isbase64 (char ch) +{ + return isubase64 (ch); +} extern void base64_encode (const char *restrict in, idx_t inlen, char *restrict out, idx_t outlen); extern idx_t base64_encode_alloc (const char *in, idx_t inlen, char **out); -extern void base64_decode_ctx_init (struct base64_decode_context *ctx); +/* Initialize decode-context buffer, CTX. */ +BASE64_INLINE void +base64_decode_ctx_init (struct base64_decode_context *ctx) +{ + ctx->i = 0; +} extern bool base64_decode_ctx (struct base64_decode_context *ctx, const char *restrict in, idx_t inlen, @@ -58,8 +90,10 @@ extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx, #define base64_decode_alloc(in, inlen, out, outlen) \ base64_decode_alloc_ctx (NULL, in, inlen, out, outlen) -# ifdef __cplusplus +#ifdef __cplusplus } -# endif +#endif + +_GL_INLINE_HEADER_END #endif /* BASE64_H */ diff --git a/gl/basename-lgpl.c b/gl/basename-lgpl.c index 6de60aa..256f846 100644 --- a/gl/basename-lgpl.c +++ b/gl/basename-lgpl.c @@ -1,6 +1,6 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify diff --git a/gl/basename-lgpl.h b/gl/basename-lgpl.h index 5d996c1..2a56be9 100644 --- a/gl/basename-lgpl.h +++ b/gl/basename-lgpl.h @@ -1,6 +1,6 @@ /* Extract the last component (base name) of a file name. - Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation, + Copyright (C) 1998, 2001, 2003-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -19,6 +19,11 @@ #ifndef _BASENAME_LGPL_H #define _BASENAME_LGPL_H +/* This file uses _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT diff --git a/gl/basename.c b/gl/basename.c index 21fab1e..c5a6bdc 100644 --- a/gl/basename.c +++ b/gl/basename.c @@ -1,6 +1,6 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/gl/btowc.c b/gl/btowc.c index caadbd7..8bf21aa 100644 --- a/gl/btowc.c +++ b/gl/btowc.c @@ -1,5 +1,5 @@ /* Convert unibyte character to wide character. - Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This file is free software: you can redistribute it and/or modify @@ -22,6 +22,7 @@ #include #include +#include wint_t btowc (int c) @@ -32,7 +33,14 @@ btowc (int c) wchar_t wc; buf[0] = c; +#if HAVE_MBRTOWC + mbstate_t state; + mbszero (&state); + size_t ret = mbrtowc (&wc, buf, 1, &state); + if (!(ret == (size_t)(-1) || ret == (size_t)(-2))) +#else if (mbtowc (&wc, buf, 1) >= 0) +#endif return wc; } return WEOF; diff --git a/gl/byteswap.in.h b/gl/byteswap.in.h index e61be27..8e49efa 100644 --- a/gl/byteswap.in.h +++ b/gl/byteswap.in.h @@ -1,5 +1,5 @@ /* byteswap.h - Byte swapping - Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc. Written by Oskar Liljeblad , 2005. This file is free software: you can redistribute it and/or modify diff --git a/gl/c++defs.h b/gl/c++defs.h index 8ad4695..eb66967 100644 --- a/gl/c++defs.h +++ b/gl/c++defs.h @@ -1,5 +1,5 @@ /* C++ compatible function declaration macros. - Copyright (C) 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2010-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -99,6 +99,12 @@ Example: _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1))); + + Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front + of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's + because + [[...]] extern "C" ; + is invalid syntax in C++.) */ #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) diff --git a/gl/calloc.c b/gl/calloc.c index 08843ac..81dfd3e 100644 --- a/gl/calloc.c +++ b/gl/calloc.c @@ -1,6 +1,6 @@ /* calloc() function that is glibc compatible. This wrapper function is required at least on Tru64 UNIX 5.1 and mingw. - Copyright (C) 2004-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2004-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/cdefs.h b/gl/cdefs.h index 09a3d19..d38382a 100644 --- a/gl/cdefs.h +++ b/gl/cdefs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2023 Free Software Foundation, Inc. +/* Copyright (C) 1992-2024 Free Software Foundation, Inc. Copyright The GNU Toolchain Authors. This file is part of the GNU C Library. @@ -42,8 +42,8 @@ #if (defined __has_attribute \ && (!defined __clang_minor__ \ || (defined __apple_build_version__ \ - ? 6000000 <= __apple_build_version__ \ - : 3 < __clang_major__ + (5 <= __clang_minor__)))) + ? 7000000 <= __apple_build_version__ \ + : 5 <= __clang_major__))) # define __glibc_has_attribute(attr) __has_attribute (attr) #else # define __glibc_has_attribute(attr) 0 @@ -140,32 +140,37 @@ #endif +/* Gnulib avoids these definitions, as they don't work on non-glibc platforms. + In particular, __bos and __bos0 are defined differently in the Android libc. + */ +#ifndef __GNULIB_CDEFS + /* Fortify support. */ -#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) -#define __bos0(ptr) __builtin_object_size (ptr, 0) +# define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) +# define __bos0(ptr) __builtin_object_size (ptr, 0) /* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */ -#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \ - || __GNUC_PREREQ (12, 0)) -# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0) -# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1) -#else -# define __glibc_objsize0(__o) __bos0 (__o) -# define __glibc_objsize(__o) __bos (__o) -#endif +# if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \ + || __GNUC_PREREQ (12, 0)) +# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0) +# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1) +# else +# define __glibc_objsize0(__o) __bos0 (__o) +# define __glibc_objsize(__o) __bos (__o) +# endif /* Compile time conditions to choose between the regular, _chk and _chk_warn variants. These conditions should get evaluated to constant and optimized away. */ -#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s)) -#define __glibc_unsigned_or_positive(__l) \ +# define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s)) +# define __glibc_unsigned_or_positive(__l) \ ((__typeof (__l)) 0 < (__typeof (__l)) -1 \ || (__builtin_constant_p (__l) && (__l) > 0)) /* Length is known to be safe at compile time if the __L * __S <= __OBJSZ condition can be folded to a constant and if it is true, or unknown (-1) */ -#define __glibc_safe_or_unknown_len(__l, __s, __osz) \ +# define __glibc_safe_or_unknown_len(__l, __s, __osz) \ ((__osz) == (__SIZE_TYPE__) -1 \ || (__glibc_unsigned_or_positive (__l) \ && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ @@ -175,7 +180,7 @@ /* Conversely, we know at compile time that the length is unsafe if the __L * __S <= __OBJSZ condition can be folded to a constant and if it is false. */ -#define __glibc_unsafe_len(__l, __s, __osz) \ +# define __glibc_unsafe_len(__l, __s, __osz) \ (__glibc_unsigned_or_positive (__l) \ && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ __s, __osz)) \ @@ -184,7 +189,7 @@ /* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be declared. */ -#define __glibc_fortify(f, __l, __s, __osz, ...) \ +# define __glibc_fortify(f, __l, __s, __osz, ...) \ (__glibc_safe_or_unknown_len (__l, __s, __osz) \ ? __ ## f ## _alias (__VA_ARGS__) \ : (__glibc_unsafe_len (__l, __s, __osz) \ @@ -194,13 +199,16 @@ /* Fortify function f, where object size argument passed to f is the number of elements and not total size. */ -#define __glibc_fortify_n(f, __l, __s, __osz, ...) \ +# define __glibc_fortify_n(f, __l, __s, __osz, ...) \ (__glibc_safe_or_unknown_len (__l, __s, __osz) \ ? __ ## f ## _alias (__VA_ARGS__) \ : (__glibc_unsafe_len (__l, __s, __osz) \ ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \ : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \ +#endif + + #if __GNUC_PREREQ (4,3) # define __warnattr(msg) __attribute__((__warning__ (msg))) # define __errordecl(name, msg) \ diff --git a/gl/cloexec.c b/gl/cloexec.c index e4cecbd..cdb0d74 100644 --- a/gl/cloexec.c +++ b/gl/cloexec.c @@ -1,6 +1,6 @@ /* cloexec.c - set or clear the close-on-exec descriptor flag - Copyright (C) 1991, 2004-2006, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 1991, 2004-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/cloexec.h b/gl/cloexec.h index 057fd66..a7944d6 100644 --- a/gl/cloexec.h +++ b/gl/cloexec.h @@ -1,6 +1,6 @@ /* cloexec.c - set or clear the close-on-exec descriptor flag - Copyright (C) 2004, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2004, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -15,6 +15,11 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ +#ifdef __cplusplus +extern "C" { +#endif + + /* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true, or clear the flag if VALUE is false. Return 0 on success, or -1 on error with 'errno' set. @@ -32,3 +37,8 @@ int set_cloexec_flag (int desc, bool value); be duplicated. */ int dup_cloexec (int fd); + + +#ifdef __cplusplus +} +#endif diff --git a/gl/close.c b/gl/close.c index 3c1b09e..830fd82 100644 --- a/gl/close.c +++ b/gl/close.c @@ -1,5 +1,5 @@ /* close replacement. - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/dirname-lgpl.c b/gl/dirname-lgpl.c index e9454af..8333c0e 100644 --- a/gl/dirname-lgpl.c +++ b/gl/dirname-lgpl.c @@ -1,6 +1,6 @@ /* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify diff --git a/gl/dirname.c b/gl/dirname.c index e72f713..393ec1b 100644 --- a/gl/dirname.c +++ b/gl/dirname.c @@ -1,6 +1,6 @@ /* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/gl/dirname.h b/gl/dirname.h index f98e83b..33935ba 100644 --- a/gl/dirname.h +++ b/gl/dirname.h @@ -1,6 +1,6 @@ /* Take file names apart into directory and base names. - Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation, + Copyright (C) 1998, 2001, 2003-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -19,6 +19,12 @@ #ifndef DIRNAME_H_ # define DIRNAME_H_ 1 +/* This file uses _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_PURE, + _GL_ATTRIBUTE_RETURNS_NONNULL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + # include # include "filename.h" # include "basename-lgpl.h" diff --git a/gl/dup2.c b/gl/dup2.c index 7d197ca..916e113 100644 --- a/gl/dup2.c +++ b/gl/dup2.c @@ -1,6 +1,6 @@ /* Duplicate an open file descriptor to a specified file descriptor. - Copyright (C) 1999, 2004-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 1999, 2004-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/dynarray.h b/gl/dynarray.h index 9155910..8940e81 100644 --- a/gl/dynarray.h +++ b/gl/dynarray.h @@ -1,5 +1,5 @@ /* Type-safe arrays which grow dynamically. - Copyright 2021-2023 Free Software Foundation, Inc. + Copyright 2021-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/errno.in.h b/gl/errno.in.h index 3dda9c2..aa658e6 100644 --- a/gl/errno.in.h +++ b/gl/errno.in.h @@ -1,6 +1,6 @@ /* A POSIX-like . - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/error.c b/gl/error.c index 6875f13..c53dfeb 100644 --- a/gl/error.c +++ b/gl/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 1990-1998, 2000-2007, 2009-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. This file is free software: you can redistribute it and/or modify @@ -19,9 +19,10 @@ #if !_LIBC # include +# define _GL_NO_INLINE_ERROR #endif -#include "error.h" +#include #include #include @@ -42,8 +43,6 @@ # define USE_UNLOCKED_IO 0 # define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b) # define _GL_ARG_NONNULL(a) -#else -# include "getprogname.h" #endif #if USE_UNLOCKED_IO diff --git a/gl/error.h b/gl/error.h deleted file mode 100644 index a240526..0000000 --- a/gl/error.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Declaration for error-reporting function - Copyright (C) 1995-1997, 2003, 2006, 2008-2023 Free Software Foundation, - Inc. - This file is part of the GNU C Library. - - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - This file is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -#ifndef _ERROR_H -#define _ERROR_H 1 - -/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Print a message with 'fprintf (stderr, FORMAT, ...)'; - if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). - If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */ - -extern void error (int __status, int __errnum, const char *__format, ...) -#if GNULIB_VFPRINTF_POSIX - _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 4)) -#else - _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 3, 4)) -#endif - ; - -extern void error_at_line (int __status, int __errnum, const char *__fname, - unsigned int __lineno, const char *__format, ...) -#if GNULIB_VFPRINTF_POSIX - _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 6)) -#else - _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 5, 6)) -#endif - ; - -/* If NULL, error will flush stdout, then print on stderr the program - name, a colon and a space. Otherwise, error will call this - function without parameters instead. */ -extern void (*error_print_progname) (void); - -/* This variable is incremented each time 'error' is called. */ -extern unsigned int error_message_count; - -/* Sometimes we want to have at most one error per line. This - variable controls whether this mode is selected or not. */ -extern int error_one_per_line; - -#ifdef __cplusplus -} -#endif - -#endif /* error.h */ diff --git a/gl/error.in.h b/gl/error.in.h new file mode 100644 index 0000000..51f8caf --- /dev/null +++ b/gl/error.in.h @@ -0,0 +1,216 @@ +/* Declarations for error-reporting functions. + Copyright (C) 1995-1997, 2003, 2006, 2008-2024 Free Software Foundation, + Inc. + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_ERROR_H + +/* No @PRAGMA_SYSTEM_HEADER@ here, because it would prevent + -Wimplicit-fallthrough warnings for missing FALLTHROUGH after error(...) + or error_at_line(...) invocations. */ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_ERROR_H@ +# @INCLUDE_NEXT@ @NEXT_ERROR_H@ +#endif + +#ifndef _@GUARD_PREFIX@_ERROR_H +#define _@GUARD_PREFIX@_ERROR_H + +/* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_FORMAT, + _GL_ATTRIBUTE_MAYBE_UNUSED. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get 'unreachable'. */ +#include + +/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */ +#include + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +#if GNULIB_VFPRINTF_POSIX +# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD +#else +# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM +#endif + +/* Helper macro for supporting the compiler's control flow analysis better. + It evaluates its arguments only once. + Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */ +#if defined __GNUC__ || defined __clang__ +/* Use 'unreachable' to tell the compiler when the function call does not + return. */ +# define __gl_error_call1(function, status, ...) \ + ((function) (status, __VA_ARGS__), \ + (status) != 0 ? unreachable () : (void) 0) +/* If STATUS is a not a constant, the function call may or may not return; + therefore -Wimplicit-fallthrough will produce a warning. Use a compound + statement in order to evaluate STATUS only once. + If STATUS is a constant, we don't use a compound statement, because that + would trigger a -Wimplicit-fallthrough warning even when STATUS is != 0, + when not optimizing. This causes STATUS to be evaluated twice, but + that's OK since it does not have side effects. */ +# define __gl_error_call(function, status, ...) \ + (__builtin_constant_p (status) \ + ? __gl_error_call1 (function, status, __VA_ARGS__) \ + : __extension__ \ + ({ \ + int const __errstatus = status; \ + __gl_error_call1 (function, __errstatus, __VA_ARGS__); \ + })) +#else +# define __gl_error_call(function, status, ...) \ + (function) (status, __VA_ARGS__) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Print a message with 'fprintf (stderr, FORMAT, ...)'; + if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). + If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */ +#if @REPLACE_ERROR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef error +# define error rpl_error +# endif +_GL_FUNCDECL_RPL (error, void, + (int __status, int __errnum, const char *__format, ...) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); +_GL_CXXALIAS_RPL (error, void, + (int __status, int __errnum, const char *__format, ...)); +# ifndef _GL_NO_INLINE_ERROR +# undef error +# define error(status, ...) \ + __gl_error_call (rpl_error, status, __VA_ARGS__) +# endif +#else +# if ! @HAVE_ERROR@ +_GL_FUNCDECL_SYS (error, void, + (int __status, int __errnum, const char *__format, ...) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); +# endif +_GL_CXXALIAS_SYS (error, void, + (int __status, int __errnum, const char *__format, ...)); +# ifndef _GL_NO_INLINE_ERROR +# ifdef error +/* Only gcc ≥ 4.7 has __builtin_va_arg_pack. */ +# if _GL_GNUC_PREREQ (4, 7) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wattributes" +_GL_ATTRIBUTE_MAYBE_UNUSED +static void +_GL_ATTRIBUTE_ALWAYS_INLINE +_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)) +_gl_inline_error (int __status, int __errnum, const char *__format, ...) +{ + return error (__status, __errnum, __format, __builtin_va_arg_pack ()); +} +# pragma GCC diagnostic pop +# undef error +# define error(status, ...) \ + __gl_error_call (_gl_inline_error, status, __VA_ARGS__) +# endif +# else +# define error(status, ...) \ + __gl_error_call (error, status, __VA_ARGS__) +# endif +# endif +#endif +#if __GLIBC__ >= 2 +_GL_CXXALIASWARN (error); +#endif + +/* Likewise. If FILENAME is non-NULL, include FILENAME:LINENO: in the + message. */ +#if @REPLACE_ERROR_AT_LINE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef error_at_line +# define error_at_line rpl_error_at_line +# endif +_GL_FUNCDECL_RPL (error_at_line, void, + (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); +_GL_CXXALIAS_RPL (error_at_line, void, + (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...)); +# ifndef _GL_NO_INLINE_ERROR +# undef error_at_line +# define error_at_line(status, ...) \ + __gl_error_call (rpl_error_at_line, status, __VA_ARGS__) +# endif +#else +# if ! @HAVE_ERROR_AT_LINE@ +_GL_FUNCDECL_SYS (error_at_line, void, + (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); +# endif +_GL_CXXALIAS_SYS (error_at_line, void, + (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...)); +# ifndef _GL_NO_INLINE_ERROR +# ifdef error_at_line +/* Only gcc ≥ 4.7 has __builtin_va_arg_pack. */ +# if _GL_GNUC_PREREQ (4, 7) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wattributes" +_GL_ATTRIBUTE_MAYBE_UNUSED +static void +_GL_ATTRIBUTE_ALWAYS_INLINE +_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)) +_gl_inline_error_at_line (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...) +{ + return error_at_line (__status, __errnum, __filename, __lineno, __format, + __builtin_va_arg_pack ()); +} +# pragma GCC diagnostic pop +# undef error_at_line +# define error_at_line(status, ...) \ + __gl_error_call (_gl_inline_error_at_line, status, __VA_ARGS__) +# endif +# else +# define error_at_line(status, ...) \ + __gl_error_call (error_at_line, status, __VA_ARGS__) +# endif +# endif +#endif +_GL_CXXALIASWARN (error_at_line); + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +extern void (*error_print_progname) (void); + +/* This variable is incremented each time 'error' is called. */ +extern unsigned int error_message_count; + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +extern int error_one_per_line; + +#ifdef __cplusplus +} +#endif + +#endif /* _@GUARD_PREFIX@_ERROR_H */ +#endif /* _@GUARD_PREFIX@_ERROR_H */ diff --git a/gl/exitfail.c b/gl/exitfail.c index d67a130..8a5962e 100644 --- a/gl/exitfail.c +++ b/gl/exitfail.c @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/exitfail.h b/gl/exitfail.h index 85a6af6..fa264b5 100644 --- a/gl/exitfail.h +++ b/gl/exitfail.h @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -15,4 +15,14 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ +#ifdef __cplusplus +extern "C" { +#endif + + extern int volatile exit_failure; + + +#ifdef __cplusplus +} +#endif diff --git a/gl/fcntl.c b/gl/fcntl.c index e220800..7cd3a0f 100644 --- a/gl/fcntl.c +++ b/gl/fcntl.c @@ -1,6 +1,6 @@ /* Provide file descriptor control. - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/fcntl.in.h b/gl/fcntl.in.h index e034eaf..eea3b95 100644 --- a/gl/fcntl.in.h +++ b/gl/fcntl.in.h @@ -1,6 +1,6 @@ /* Like , but with non-working flags defined to 0. - Copyright (C) 2006-2023 Free Software Foundation, Inc. + Copyright (C) 2006-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -74,6 +74,11 @@ #ifndef _@GUARD_PREFIX@_FCNTL_H #define _@GUARD_PREFIX@_FCNTL_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ # include #endif diff --git a/gl/fd-hook.c b/gl/fd-hook.c index 3626115..75bbe49 100644 --- a/gl/fd-hook.c +++ b/gl/fd-hook.c @@ -1,5 +1,5 @@ /* Hook for making file descriptor functions close(), ioctl() extensible. - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2009. This file is free software: you can redistribute it and/or modify diff --git a/gl/fd-hook.h b/gl/fd-hook.h index 6bf3c24..2150460 100644 --- a/gl/fd-hook.h +++ b/gl/fd-hook.h @@ -1,5 +1,5 @@ /* Hook for making file descriptor functions close(), ioctl() extensible. - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/fflush.c b/gl/fflush.c index f3689b3..36cc14d 100644 --- a/gl/fflush.c +++ b/gl/fflush.c @@ -1,5 +1,5 @@ /* fflush.c -- allow flushing input streams - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/filename.h b/gl/filename.h index a2400a9..4f0f0fb 100644 --- a/gl/filename.h +++ b/gl/filename.h @@ -1,5 +1,5 @@ /* Basic filename support macros. - Copyright (C) 2001-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/gl/float+.h b/gl/float+.h index e7531e4..104f477 100644 --- a/gl/float+.h +++ b/gl/float+.h @@ -1,5 +1,5 @@ /* Supplemental information about the floating-point formats. - Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This file is free software: you can redistribute it and/or modify diff --git a/gl/float.c b/gl/float.c index f81ff33..a9ea40b 100644 --- a/gl/float.c +++ b/gl/float.c @@ -1,5 +1,5 @@ /* Auxiliary definitions for . - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2011. This file is free software: you can redistribute it and/or modify diff --git a/gl/float.in.h b/gl/float.in.h index bf2c502..73e8d40 100644 --- a/gl/float.in.h +++ b/gl/float.in.h @@ -1,6 +1,6 @@ /* A correct . - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/floor.c b/gl/floor.c index 238f487..392f204 100644 --- a/gl/floor.c +++ b/gl/floor.c @@ -1,5 +1,5 @@ /* Round towards negative infinity. - Copyright (C) 2007, 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2007, 2010-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/floorf.c b/gl/floorf.c index e465c18..f9785d0 100644 --- a/gl/floorf.c +++ b/gl/floorf.c @@ -1,5 +1,5 @@ /* Round towards negative infinity. - Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/fopen.c b/gl/fopen.c index f8469a0..d3b57a9 100644 --- a/gl/fopen.c +++ b/gl/fopen.c @@ -1,5 +1,5 @@ /* Open a stream to a file. - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -33,9 +33,13 @@ orig_fopen (const char *filename, const char *mode) } /* Specification. */ +#ifdef __osf__ /* Write "stdio.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "stdio.h" +# include "stdio.h" +#else +# include +#endif #include #include @@ -225,5 +229,9 @@ rpl_fopen (const char *filename, const char *mode) } #endif + /* open_direction is sometimes used, sometimes unused. + Silence gcc's warning about this situation. */ + (void) open_direction; + return orig_fopen (filename, mode); } diff --git a/gl/fpurge.c b/gl/fpurge.c index 0dcb2b7..52a3dce 100644 --- a/gl/fpurge.c +++ b/gl/fpurge.c @@ -1,5 +1,5 @@ /* Flushing buffers of a FILE stream. - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/freading.c b/gl/freading.c index b9377cb..c80d9aa 100644 --- a/gl/freading.c +++ b/gl/freading.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/freading.h b/gl/freading.h index 27b3abb..943354f 100644 --- a/gl/freading.h +++ b/gl/freading.h @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -14,6 +14,11 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ +/* This file uses _GL_ATTRIBUTE_PURE, HAVE___FREADING, HAVE_STDIO_EXT_H. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include /* Return true if the stream STREAM is opened read-only, or if the diff --git a/gl/free.c b/gl/free.c index 372a6b0..2f0c40b 100644 --- a/gl/free.c +++ b/gl/free.c @@ -1,6 +1,6 @@ /* Make free() preserve errno. - Copyright (C) 2003, 2006, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/fseek.c b/gl/fseek.c index 9764375..cebc174 100644 --- a/gl/fseek.c +++ b/gl/fseek.c @@ -1,5 +1,5 @@ /* An fseek() function that, together with fflush(), is POSIX compliant. - Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/fseeko.c b/gl/fseeko.c index 89a7087..2c3b053 100644 --- a/gl/fseeko.c +++ b/gl/fseeko.c @@ -1,5 +1,5 @@ /* An fseeko() function that, together with fflush(), is POSIX compliant. - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/fstat.c b/gl/fstat.c index 6a23500..205d5aa 100644 --- a/gl/fstat.c +++ b/gl/fstat.c @@ -1,5 +1,5 @@ /* fstat() replacement. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/fsusage.c b/gl/fsusage.c index f6f4b1c..97d0eef 100644 --- a/gl/fsusage.c +++ b/gl/fsusage.c @@ -1,6 +1,6 @@ /* fsusage.c -- return space usage of mounted file systems - Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2023 Free Software + Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify diff --git a/gl/fsusage.h b/gl/fsusage.h index 9630b04..da87859 100644 --- a/gl/fsusage.h +++ b/gl/fsusage.h @@ -1,6 +1,6 @@ /* fsusage.h -- declarations for file system space usage info - Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2023 Free Software + Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -19,9 +19,14 @@ /* Space usage statistics for a file system. Blocks are 512-byte. */ #if !defined FSUSAGE_H_ -# define FSUSAGE_H_ +#define FSUSAGE_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif -# include struct fs_usage { @@ -36,4 +41,9 @@ struct fs_usage int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/gl/ftell.c b/gl/ftell.c index ce2bd54..21cab43 100644 --- a/gl/ftell.c +++ b/gl/ftell.c @@ -1,5 +1,5 @@ /* An ftell() function that works around platform bugs. - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/ftello.c b/gl/ftello.c index 14184e5..64119aa 100644 --- a/gl/ftello.c +++ b/gl/ftello.c @@ -1,5 +1,5 @@ /* An ftello() function that works around platform bugs. - Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/gai_strerror.c b/gl/gai_strerror.c index 3436c07..37092e2 100644 --- a/gl/gai_strerror.c +++ b/gl/gai_strerror.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2023 Free Software +/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Philip Blundell , 1997. diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c index 6586ee5..bf5d61f 100644 --- a/gl/getaddrinfo.c +++ b/gl/getaddrinfo.c @@ -1,5 +1,5 @@ /* Get address information (partial implementation). - Copyright (C) 1997, 2001-2002, 2004-2023 Free Software Foundation, Inc. + Copyright (C) 1997, 2001-2002, 2004-2024 Free Software Foundation, Inc. Contributed by Simon Josefsson . This file is free software: you can redistribute it and/or modify diff --git a/gl/getdelim.c b/gl/getdelim.c index 79ec3dd..58063b1 100644 --- a/gl/getdelim.c +++ b/gl/getdelim.c @@ -1,5 +1,5 @@ /* getdelim.c --- Implementation of replacement getdelim function. - Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2023 Free Software + Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -30,10 +30,6 @@ #include #include -#ifndef SSIZE_MAX -# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) -#endif - #if USE_UNLOCKED_IO # include "unlocked-io.h" # define getc_maybe_unlocked(fp) getc(fp) diff --git a/gl/getdtablesize.c b/gl/getdtablesize.c index ac2d175..762c100 100644 --- a/gl/getdtablesize.c +++ b/gl/getdtablesize.c @@ -1,5 +1,5 @@ /* getdtablesize() function: Return maximum possible file descriptor value + 1. - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This file is free software: you can redistribute it and/or modify diff --git a/gl/gethostname.c b/gl/gethostname.c index 0c616c3..c075b6d 100644 --- a/gl/gethostname.c +++ b/gl/gethostname.c @@ -1,6 +1,6 @@ /* gethostname emulation for SysV and POSIX.1. - Copyright (C) 1992, 2003, 2006, 2008-2023 Free Software Foundation, Inc. + Copyright (C) 1992, 2003, 2006, 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/getline.c b/gl/getline.c index 85f16ab..2d03b64 100644 --- a/gl/getline.c +++ b/gl/getline.c @@ -1,5 +1,5 @@ /* getline.c --- Implementation of replacement getline function. - Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/getloadavg.c b/gl/getloadavg.c index 59b53e7..c940e4c 100644 --- a/gl/getloadavg.c +++ b/gl/getloadavg.c @@ -1,6 +1,6 @@ /* Get the system load averages. - Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2023 Free Software + Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2024 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with gnulib. diff --git a/gl/getopt-cdefs.in.h b/gl/getopt-cdefs.in.h index e76c78c..a1d304d 100644 --- a/gl/getopt-cdefs.in.h +++ b/gl/getopt-cdefs.in.h @@ -1,5 +1,5 @@ /* getopt-on-non-glibc compatibility macros. - Copyright (C) 1989-2023 Free Software Foundation, Inc. + Copyright (C) 1989-2024 Free Software Foundation, Inc. This file is part of gnulib. Unlike most of the getopt implementation, it is NOT shared with the GNU C Library. @@ -57,7 +57,11 @@ #ifndef __THROW # if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4) -# define __THROW throw () +# if __cplusplus >= 201103L +# define __THROW noexcept (true) +# else +# define __THROW throw () +# endif # else # define __THROW # endif diff --git a/gl/getopt-core.h b/gl/getopt-core.h index c5dd493..12d09a2 100644 --- a/gl/getopt-core.h +++ b/gl/getopt-core.h @@ -1,5 +1,5 @@ /* Declarations for getopt (basic, portable features only). - Copyright (C) 1989-2023 Free Software Foundation, Inc. + Copyright (C) 1989-2024 Free Software Foundation, Inc. This file is part of the GNU C Library and is also part of gnulib. Patches to this file should be submitted to both projects. diff --git a/gl/getopt-ext.h b/gl/getopt-ext.h index d37c293..e4b499d 100644 --- a/gl/getopt-ext.h +++ b/gl/getopt-ext.h @@ -1,5 +1,5 @@ /* Declarations for getopt (GNU extensions). - Copyright (C) 1989-2023 Free Software Foundation, Inc. + Copyright (C) 1989-2024 Free Software Foundation, Inc. This file is part of the GNU C Library and is also part of gnulib. Patches to this file should be submitted to both projects. diff --git a/gl/getopt-pfx-core.h b/gl/getopt-pfx-core.h index 3a2fde5..78b7816 100644 --- a/gl/getopt-pfx-core.h +++ b/gl/getopt-pfx-core.h @@ -1,5 +1,5 @@ /* getopt (basic, portable features) gnulib wrapper header. - Copyright (C) 1989-2023 Free Software Foundation, Inc. + Copyright (C) 1989-2024 Free Software Foundation, Inc. This file is part of gnulib. Unlike most of the getopt implementation, it is NOT shared with the GNU C Library. @@ -47,7 +47,7 @@ # define optind __GETOPT_ID (optind) # define optopt __GETOPT_ID (optopt) -/* Work around a a problem on macOS, which declares getopt with a +/* Work around a problem on macOS, which declares getopt with a trailing __DARWIN_ALIAS(getopt) that would expand to something like __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following hack to suppress the macOS declaration . */ diff --git a/gl/getopt-pfx-ext.h b/gl/getopt-pfx-ext.h index 8578d72..f001c11 100644 --- a/gl/getopt-pfx-ext.h +++ b/gl/getopt-pfx-ext.h @@ -1,5 +1,5 @@ /* getopt (GNU extensions) gnulib wrapper header. - Copyright (C) 1989-2023 Free Software Foundation, Inc. + Copyright (C) 1989-2024 Free Software Foundation, Inc. This file is part of gnulib. Unlike most of the getopt implementation, it is NOT shared with the GNU C Library. diff --git a/gl/getopt.c b/gl/getopt.c index 1e2441c..f66f119 100644 --- a/gl/getopt.c +++ b/gl/getopt.c @@ -1,5 +1,5 @@ /* Getopt for GNU. - Copyright (C) 1987-2023 Free Software Foundation, Inc. + Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of the GNU C Library and is also part of gnulib. Patches to this file should be submitted to both projects. @@ -21,7 +21,7 @@ # include #endif -#include "getopt.h" +#include #include #include @@ -223,8 +223,9 @@ process_long_option (int argc, char **argv, const char *optstring, { /* Didn't find an exact match, so look for abbreviations. */ unsigned char *ambig_set = NULL; - int ambig_malloced = 0; - int ambig_fallback = 0; + /* Use simpler fallback diagnostic if ambig_set == &ambig_fallback. */ + unsigned char ambig_fallback; + void *ambig_malloced = NULL; int indfound = -1; for (p = longopts, option_index = 0; p->name; p++, option_index++) @@ -242,39 +243,42 @@ process_long_option (int argc, char **argv, const char *optstring, || pfound->val != p->val) { /* Second or later nonexact match found. */ - if (!ambig_fallback) + if (ambig_set != &ambig_fallback) { if (!print_errors) /* Don't waste effort tracking the ambig set if we're not going to print it anyway. */ - ambig_fallback = 1; + ambig_set = &ambig_fallback; else if (!ambig_set) { if (__libc_use_alloca (n_options)) ambig_set = alloca (n_options); - else if ((ambig_set = malloc (n_options)) == NULL) - /* Fall back to simpler error message. */ - ambig_fallback = 1; else - ambig_malloced = 1; + { + ambig_malloced = malloc (n_options); + /* Fall back to simpler diagnostic if + memory allocation fails. */ + ambig_set = (ambig_malloced ? ambig_malloced + : &ambig_fallback); + } - if (ambig_set) + if (ambig_set != &ambig_fallback) { memset (ambig_set, 0, n_options); ambig_set[indfound] = 1; } } - if (ambig_set) + if (ambig_set && ambig_set != &ambig_fallback) ambig_set[option_index] = 1; } } } - if (ambig_set || ambig_fallback) + if (ambig_set) { if (print_errors) { - if (ambig_fallback) + if (ambig_set == &ambig_fallback) fprintf (stderr, _("%s: option '%s%s' is ambiguous\n"), argv[0], prefix, d->__nextchar); else @@ -296,8 +300,7 @@ process_long_option (int argc, char **argv, const char *optstring, funlockfile (stderr); } } - if (ambig_malloced) - free (ambig_set); + free (ambig_malloced); d->__nextchar += strlen (d->__nextchar); d->optind++; d->optopt = 0; diff --git a/gl/getopt.in.h b/gl/getopt.in.h index 0867d36..c2411a7 100644 --- a/gl/getopt.in.h +++ b/gl/getopt.in.h @@ -1,5 +1,5 @@ /* Declarations for getopt. - Copyright (C) 1989-2023 Free Software Foundation, Inc. + Copyright (C) 1989-2024 Free Software Foundation, Inc. This file is part of gnulib. Unlike most of the getopt implementation, it is NOT shared with the GNU C Library, which supplies a different version of diff --git a/gl/getopt1.c b/gl/getopt1.c index 49323aa..c42d29f 100644 --- a/gl/getopt1.c +++ b/gl/getopt1.c @@ -1,5 +1,5 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987-2023 Free Software Foundation, Inc. + Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of the GNU C Library and is also part of gnulib. Patches to this file should be submitted to both projects. @@ -21,7 +21,7 @@ # include #endif -#include "getopt.h" +#include #include "getopt_int.h" int diff --git a/gl/getopt_int.h b/gl/getopt_int.h index 4d9e24b..c00c0b6 100644 --- a/gl/getopt_int.h +++ b/gl/getopt_int.h @@ -1,5 +1,5 @@ /* Internal declarations for getopt. - Copyright (C) 1989-2023 Free Software Foundation, Inc. + Copyright (C) 1989-2024 Free Software Foundation, Inc. This file is part of the GNU C Library and is also part of gnulib. Patches to this file should be submitted to both projects. diff --git a/gl/getprogname.c b/gl/getprogname.c index 32c9604..392a9a2 100644 --- a/gl/getprogname.c +++ b/gl/getprogname.c @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2016-2023 Free Software Foundation, Inc. + Copyright (C) 2016-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -16,11 +16,10 @@ #include -/* Specification. */ -#include "getprogname.h" +/* Specification. Also get __argv declaration. */ +#include #include /* get program_invocation_name declaration */ -#include /* get __argv declaration */ #ifdef _AIX # include @@ -53,13 +52,12 @@ #if defined __SCO_VERSION__ || defined __sysv5__ # include -# include # include #endif #include "basename-lgpl.h" -#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */ +#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Solaris >= 11, Cygwin, Android API level >= 21 */ char const * getprogname (void) { @@ -214,7 +212,19 @@ getprogname (void) { char *s = strdup (last_component (buf.ps_pathptr)); if (s) - p = s; + { +# if defined __XPLINK__ && __CHARSET_LIB == 1 + /* The compiler option -qascii is in use. + https://makingdeveloperslivesbetter.wordpress.com/2022/01/07/is-z-os-ascii-or-ebcdic-yes/ + https://www.ibm.com/docs/en/zos/2.5.0?topic=features-macros-related-compiler-option-settings + So, convert the result from EBCDIC to ASCII. + https://www.ibm.com/docs/en/zos/2.5.0?topic=functions-e2a-s-convert-string-from-ebcdic-ascii */ + if (__e2a_s (s) == (size_t)-1) + free (s); + else +# endif + p = s; + } break; } } diff --git a/gl/getprogname.h b/gl/getprogname.h index 4b9126f..bee1c1a 100644 --- a/gl/getprogname.h +++ b/gl/getprogname.h @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2016-2023 Free Software Foundation, Inc. + Copyright (C) 2016-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -19,22 +19,8 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - -/* Return the base name of the executing program. - On native Windows this will usually end in ".exe" or ".EXE". */ -#ifndef HAVE_GETPROGNAME -extern char const *getprogname (void) -# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME - _GL_ATTRIBUTE_PURE -# endif - ; -#endif - -#ifdef __cplusplus -} +#if __GNUC__ || (__clang_major__ >= 4) +# warning "The include file getprogname.h is deprecated. Use instead." #endif #endif diff --git a/gl/gettext.h b/gl/gettext.h index d0462c4..39d5ae4 100644 --- a/gl/gettext.h +++ b/gl/gettext.h @@ -1,5 +1,5 @@ /* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2023 Free Software + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify diff --git a/gl/gl_openssl.h b/gl/gl_openssl.h index f63c386..0686473 100644 --- a/gl/gl_openssl.h +++ b/gl/gl_openssl.h @@ -1,6 +1,6 @@ /* Wrap openssl crypto hash routines in gnulib interface. -*- coding: utf-8 -*- - Copyright (C) 2013-2023 Free Software Foundation, Inc. + Copyright (C) 2013-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -17,13 +17,15 @@ /* Written by Pádraig Brady */ +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #ifndef GL_OPENSSL_NAME # error "Please define GL_OPENSSL_NAME to 1,5,256 etc." #endif -#ifndef _GL_INLINE_HEADER_BEGIN -# error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef GL_OPENSSL_INLINE # define GL_OPENSSL_INLINE _GL_INLINE diff --git a/gl/glthread/lock.c b/gl/glthread/lock.c index 82fb755..6661ad6 100644 --- a/gl/glthread/lock.c +++ b/gl/glthread/lock.c @@ -1,5 +1,5 @@ /* Locking in multithreaded situations. - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/glthread/lock.h b/gl/glthread/lock.h index ae3ee2d..2d5cb32 100644 --- a/gl/glthread/lock.h +++ b/gl/glthread/lock.h @@ -1,5 +1,5 @@ /* Locking in multithreaded situations. - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -77,6 +77,14 @@ #ifndef _LOCK_H #define _LOCK_H +/* This file uses HAVE_THREADS_H, HAVE_PTHREAD_RWLOCK, + HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER, + PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP, + HAVE_PTHREAD_MUTEX_RECURSIVE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include diff --git a/gl/glthread/threadlib.c b/gl/glthread/threadlib.c index 5ecf827..7a77676 100644 --- a/gl/glthread/threadlib.c +++ b/gl/glthread/threadlib.c @@ -1,5 +1,5 @@ /* Multithreading primitives. - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/hard-locale.c b/gl/hard-locale.c index 0a28552..653c580 100644 --- a/gl/hard-locale.c +++ b/gl/hard-locale.c @@ -1,6 +1,6 @@ /* hard-locale.c -- Determine whether a locale is hard. - Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2023 Free Software + Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include "hard-locale.h" #include +#include #include bool @@ -31,5 +32,16 @@ hard_locale (int category) if (setlocale_null_r (category, locale, sizeof (locale))) return false; - return !(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0); + if (!(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)) + return true; + +#if defined __ANDROID__ + /* On Android 5.0 or newer, it is possible to set a locale that has the same + name as the "C" locale but in fact uses UTF-8 encoding. Cf. test case 2 in + . */ + if (MB_CUR_MAX > 1) + return true; +#endif + + return false; } diff --git a/gl/hard-locale.h b/gl/hard-locale.h index 880c9e8..5d40e52 100644 --- a/gl/hard-locale.h +++ b/gl/hard-locale.h @@ -1,6 +1,6 @@ /* Determine whether a locale is hard. - Copyright (C) 1999, 2003-2004, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 1999, 2003-2004, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -16,11 +16,23 @@ along with this program. If not, see . */ #ifndef HARD_LOCALE_H_ -# define HARD_LOCALE_H_ 1 +#define HARD_LOCALE_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + /* Return true if the specified CATEGORY of the current locale is hard, i.e. different from the C or POSIX locale that has a fixed behavior. - CATEGORY must be one of the LC_* values, but not LC_ALL. */ + CATEGORY must be one of the LC_* values, but not LC_ALL. + Note: This function uses the current global locale; it ignores the + per-thread locale. */ extern bool hard_locale (int category); + +#ifdef __cplusplus +} +#endif + #endif /* HARD_LOCALE_H_ */ diff --git a/gl/ialloc.c b/gl/ialloc.c index cd44d8c..8564a15 100644 --- a/gl/ialloc.c +++ b/gl/ialloc.c @@ -1,6 +1,6 @@ /* malloc with idx_t rather than size_t - Copyright 2021-2023 Free Software Foundation, Inc. + Copyright 2021-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/ialloc.h b/gl/ialloc.h index 1d43faf..2aa94ae 100644 --- a/gl/ialloc.h +++ b/gl/ialloc.h @@ -1,6 +1,6 @@ /* ialloc.h -- malloc with idx_t rather than size_t - Copyright 2021-2023 Free Software Foundation, Inc. + Copyright 2021-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,15 +18,21 @@ #ifndef IALLOC_H_ #define IALLOC_H_ +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_COLD, + _GL_ATTRIBUTE_MALLOC. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include "idx.h" #include #include #include - -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." +#if defined __CHERI_PURE_CAPABILITY__ +# include #endif + _GL_INLINE_HEADER_BEGIN #ifndef IALLOC_INLINE # define IALLOC_INLINE _GL_INLINE @@ -43,6 +49,9 @@ _gl_alloc_nomem (void) return NULL; } +/* imalloc (size) is like malloc (size). + It returns a non-NULL pointer to size bytes of memory. + Upon failure, it returns NULL with errno set. */ IALLOC_INLINE _GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/ void * @@ -51,16 +60,32 @@ imalloc (idx_t s) return s <= SIZE_MAX ? malloc (s) : _gl_alloc_nomem (); } +/* irealloc (ptr, size) is like realloc (ptr, size). + It returns a non-NULL pointer to size bytes of memory. + Upon failure, it returns NULL with errno set. */ IALLOC_INLINE /*_GL_ATTRIBUTE_DEALLOC_FREE*/ void * irealloc (void *p, idx_t s) { - /* Work around GNU realloc glitch by treating a zero size as if it - were 1, so that returning NULL is equivalent to failing. */ - return s <= SIZE_MAX ? realloc (p, s | !s) : _gl_alloc_nomem (); + if (s <= SIZE_MAX) + { + /* Work around GNU realloc glitch by treating a zero size as if it + were 1, so that returning NULL is equivalent to failing. */ + p = realloc (p, s | !s); +#if defined __CHERI_PURE_CAPABILITY__ + if (p != NULL) + p = cheri_bounds_set (p, s); +#endif + return p; + } + else + return _gl_alloc_nomem (); } +/* icalloc (num, size) is like calloc (num, size). + It returns a non-NULL pointer to num * size bytes of memory. + Upon failure, it returns NULL with errno set. */ IALLOC_INLINE _GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/ void * @@ -81,20 +106,35 @@ icalloc (idx_t n, idx_t s) return calloc (n, s); } +/* ireallocarray (ptr, num, size) is like reallocarray (ptr, num, size). + It returns a non-NULL pointer to num * size bytes of memory. + Upon failure, it returns NULL with errno set. */ IALLOC_INLINE void * ireallocarray (void *p, idx_t n, idx_t s) { - /* Work around GNU reallocarray glitch by treating a zero size as if - it were 1, so that returning NULL is equivalent to failing. */ - if (n == 0 || s == 0) - n = s = 1; - return (n <= SIZE_MAX && s <= SIZE_MAX - ? reallocarray (p, n, s) - : _gl_alloc_nomem ()); + if (n <= SIZE_MAX && s <= SIZE_MAX) + { + /* Work around GNU reallocarray glitch by treating a zero size as if + it were 1, so that returning NULL is equivalent to failing. */ + size_t nx = n; + size_t sx = s; + if (n == 0 || s == 0) + nx = sx = 1; + p = reallocarray (p, nx, sx); +#if defined __CHERI_PURE_CAPABILITY__ + if (p != NULL && (n == 0 || s == 0)) + p = cheri_bounds_set (p, 0); +#endif + return p; + } + else + return _gl_alloc_nomem (); } #ifdef __cplusplus } #endif +_GL_INLINE_HEADER_END + #endif diff --git a/gl/idpriv-droptemp.c b/gl/idpriv-droptemp.c index 2a85431..eb882de 100644 --- a/gl/idpriv-droptemp.c +++ b/gl/idpriv-droptemp.c @@ -1,5 +1,5 @@ /* Dropping uid/gid privileges of the current process temporarily. - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/idpriv.h b/gl/idpriv.h index 99f87c0..a3ae592 100644 --- a/gl/idpriv.h +++ b/gl/idpriv.h @@ -1,5 +1,5 @@ /* Dropping uid/gid privileges of the current process. - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gl/idx.h b/gl/idx.h index 23020b7..43793f2 100644 --- a/gl/idx.h +++ b/gl/idx.h @@ -1,5 +1,5 @@ /* A type for indices and sizes. - Copyright (C) 2020-2023 Free Software Foundation, Inc. + Copyright (C) 2020-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -111,6 +111,11 @@ help producing good code and good warnings. The type 'idx_t' could then be typedef'ed to a range type that is signed after promotion. */ +#ifdef __cplusplus +extern "C" { +#endif + + /* In the future, idx_t could be typedef'ed to a signed range type. The clang "extended integer types", supported in Clang 11 or newer , @@ -131,4 +136,9 @@ typedef ptrdiff_t idx_t; Perhaps there should be another macro IDX_VALUE_BITS that does not count the sign bit and is therefore one less than PTRDIFF_WIDTH. */ + +#ifdef __cplusplus +} +#endif + #endif /* _IDX_H */ diff --git a/gl/inet_ntop.c b/gl/inet_ntop.c index 9e2d412..0a4ba20 100644 --- a/gl/inet_ntop.c +++ b/gl/inet_ntop.c @@ -1,6 +1,6 @@ /* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form - Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/intprops-internal.h b/gl/intprops-internal.h index 0467a9c..b5ba8d7 100644 --- a/gl/intprops-internal.h +++ b/gl/intprops-internal.h @@ -1,6 +1,6 @@ /* intprops-internal.h -- properties of integer types not visible to users - Copyright (C) 2001-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -20,6 +20,11 @@ #include +/* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */ +#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif + /* Return a value with the common real type of E and V and the value of V. Do not evaluate E. */ #define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) @@ -164,7 +169,9 @@ /* Work around GCC bug 91450. */ # define _GL_INT_MULTIPLY_WRAPV(a, b, r) \ ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \ - && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \ + && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, \ + (__typeof__ (*(r))) 0, \ + (__typeof__ (*(r))) -1)) \ ? ((void) __builtin_mul_overflow (a, b, r), 1) \ : __builtin_mul_overflow (a, b, r)) # endif diff --git a/gl/intprops.h b/gl/intprops.h index 44b5e60..43734f3 100644 --- a/gl/intprops.h +++ b/gl/intprops.h @@ -1,6 +1,6 @@ /* intprops.h -- properties of integer types - Copyright (C) 2001-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published diff --git a/gl/inttypes.in.h b/gl/inttypes.in.h index 50a2bbf..b9ab8a4 100644 --- a/gl/inttypes.in.h +++ b/gl/inttypes.in.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2006-2023 Free Software Foundation, Inc. +/* Copyright (C) 2006-2024 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Derek Price. This file is part of gnulib. @@ -46,6 +46,11 @@ #if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H #define INTTYPES_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Include or the gnulib replacement. But avoid namespace pollution on glibc systems. */ #ifndef __GLIBC__ @@ -903,8 +908,21 @@ extern "C" { #endif #if @GNULIB_IMAXABS@ -# if !@HAVE_DECL_IMAXABS@ -extern intmax_t imaxabs (intmax_t); +# if @REPLACE_IMAXABS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef imaxabs +# define imaxabs rpl_imaxabs +# endif +_GL_FUNCDECL_RPL (imaxabs, intmax_t, (intmax_t x)); +_GL_CXXALIAS_RPL (imaxabs, intmax_t, (intmax_t x)); +# else +# if !@HAVE_DECL_IMAXABS@ +_GL_FUNCDECL_SYS (imaxabs, intmax_t, (intmax_t x)); +# endif +_GL_CXXALIAS_SYS (imaxabs, intmax_t, (intmax_t x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (imaxabs); # endif #elif defined GNULIB_POSIXCHECK # undef imaxabs @@ -921,8 +939,21 @@ typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t; # define GNULIB_defined_imaxdiv_t 1 # endif # endif -# if !@HAVE_DECL_IMAXDIV@ -extern imaxdiv_t imaxdiv (intmax_t, intmax_t); +# if @REPLACE_IMAXDIV@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef imaxdiv +# define imaxdiv rpl_imaxdiv +# endif +_GL_FUNCDECL_RPL (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom)); +_GL_CXXALIAS_RPL (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom)); +# else +# if !@HAVE_DECL_IMAXDIV@ +_GL_FUNCDECL_SYS (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom)); +# endif +_GL_CXXALIAS_SYS (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (imaxdiv); # endif #elif defined GNULIB_POSIXCHECK # undef imaxdiv diff --git a/gl/iswblank.c b/gl/iswblank.c new file mode 100644 index 0000000..f699850 --- /dev/null +++ b/gl/iswblank.c @@ -0,0 +1,26 @@ +/* Test wide character for being blank. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +int +iswblank (wint_t wc) +{ + return wc == ' ' || wc == '\t'; +} diff --git a/gl/iswctype-impl.h b/gl/iswctype-impl.h new file mode 100644 index 0000000..999f220 --- /dev/null +++ b/gl/iswctype-impl.h @@ -0,0 +1,22 @@ +/* Test whether a wide character has a given property. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +int +iswctype (wint_t wc, wctype_t desc) +{ + return ((int (*) (wint_t)) desc) (wc); +} diff --git a/gl/iswctype.c b/gl/iswctype.c new file mode 100644 index 0000000..f4e6f01 --- /dev/null +++ b/gl/iswctype.c @@ -0,0 +1,36 @@ +/* Test whether a wide character has a given property. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if GNULIB_defined_wint_t && !GNULIB_defined_wctype_t + +int +iswctype (wint_t wc, wctype_t desc) +# undef iswctype +{ + return ((wchar_t) wc == wc ? iswctype ((wchar_t) wc, desc) : 0); +} + +#else + +# include "iswctype-impl.h" + +#endif diff --git a/gl/iswdigit.c b/gl/iswdigit.c new file mode 100644 index 0000000..57363ab --- /dev/null +++ b/gl/iswdigit.c @@ -0,0 +1,26 @@ +/* Test wide character for being a digit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +int +iswdigit (wint_t wc) +{ + return wc >= '0' && wc <= '9'; +} diff --git a/gl/iswpunct.c b/gl/iswpunct.c new file mode 100644 index 0000000..c7cb28b --- /dev/null +++ b/gl/iswpunct.c @@ -0,0 +1,33 @@ +/* Test wide character for being a punctuation or symbol character. + Copyright (C) 2023-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +int +iswpunct (wint_t wc) +#undef iswpunct +{ +#if defined __ANDROID__ + if ((unsigned int) wc < 128) + return ispunct ((unsigned int) wc); +#endif + return iswpunct (wc); +} diff --git a/gl/iswxdigit.c b/gl/iswxdigit.c new file mode 100644 index 0000000..d32e3b0 --- /dev/null +++ b/gl/iswxdigit.c @@ -0,0 +1,33 @@ +/* Test wide character for being a hexadecimal digit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +int +iswxdigit (wint_t wc) +{ + return ((wc >= '0' && wc <= '9') +#if 'A' == 0x41 && 'a' == 0x61 + /* Optimization, assuming ASCII */ + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F') +#else + || (wc >= 'A' && wc <= 'F') || (wc >= 'a' && wc <= 'f') +#endif + ); +} diff --git a/gl/itold.c b/gl/itold.c index 0ef4464..e6fbcff 100644 --- a/gl/itold.c +++ b/gl/itold.c @@ -1,5 +1,5 @@ /* Replacement for 'int' to 'long double' conversion routine. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2011. This file is free software: you can redistribute it and/or modify diff --git a/gl/langinfo.in.h b/gl/langinfo.in.h index c7555a6..febbd25 100644 --- a/gl/langinfo.in.h +++ b/gl/langinfo.in.h @@ -1,5 +1,5 @@ /* Substitute for and wrapper around . - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -34,6 +34,11 @@ #ifndef _@GUARD_PREFIX@_LANGINFO_H #define _@GUARD_PREFIX@_LANGINFO_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #if !@HAVE_LANGINFO_H@ @@ -208,7 +213,9 @@ _GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item)); # endif _GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (nl_langinfo); +# endif #elif defined GNULIB_POSIXCHECK # undef nl_langinfo # if HAVE_RAW_DECL_NL_LANGINFO diff --git a/gl/lc-charset-dispatch.c b/gl/lc-charset-dispatch.c index cd74466..e2f8b2f 100644 --- a/gl/lc-charset-dispatch.c +++ b/gl/lc-charset-dispatch.c @@ -1,5 +1,5 @@ /* Dispatching based on the current locale's character encoding. - Copyright (C) 2018-2023 Free Software Foundation, Inc. + Copyright (C) 2018-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/lc-charset-dispatch.h b/gl/lc-charset-dispatch.h index c82b6a6..4c1cf5f 100644 --- a/gl/lc-charset-dispatch.h +++ b/gl/lc-charset-dispatch.h @@ -1,5 +1,5 @@ /* Dispatching based on the current locale's character encoding. - Copyright (C) 2018-2023 Free Software Foundation, Inc. + Copyright (C) 2018-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/libc-config.h b/gl/libc-config.h index 1d28e58..7011460 100644 --- a/gl/libc-config.h +++ b/gl/libc-config.h @@ -1,6 +1,6 @@ /* System definitions for code taken from the GNU C Library - Copyright 2017-2023 Free Software Foundation, Inc. + Copyright 2017-2024 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -137,8 +137,6 @@ # undef __attribute_returns_twice__ # undef __attribute_used__ # undef __attribute_warn_unused_result__ -# undef __bos -# undef __bos0 # undef __errordecl # undef __extension__ # undef __extern_always_inline @@ -147,21 +145,13 @@ # undef __fortified_attr_access # undef __fortify_function # undef __glibc_c99_flexarr_available -# undef __glibc_fortify -# undef __glibc_fortify_n # undef __glibc_has_attribute # undef __glibc_has_builtin # undef __glibc_has_extension # undef __glibc_likely # undef __glibc_macro_warning # undef __glibc_macro_warning1 -# undef __glibc_objsize -# undef __glibc_objsize0 -# undef __glibc_safe_len_cond -# undef __glibc_safe_or_unknown_len # undef __glibc_unlikely -# undef __glibc_unsafe_len -# undef __glibc_unsigned_or_positive # undef __inline # undef __ptr_t # undef __restrict @@ -170,6 +160,18 @@ # undef __va_arg_pack_len # undef __warnattr # undef __wur +# ifndef __GNULIB_CDEFS +# undef __bos +# undef __bos0 +# undef __glibc_fortify +# undef __glibc_fortify_n +# undef __glibc_objsize +# undef __glibc_objsize0 +# undef __glibc_safe_len_cond +# undef __glibc_safe_or_unknown_len +# undef __glibc_unsafe_len +# undef __glibc_unsigned_or_positive +# endif /* Include our copy of glibc . */ # include diff --git a/gl/limits.in.h b/gl/limits.in.h index eaeac47..c65eb4c 100644 --- a/gl/limits.in.h +++ b/gl/limits.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright 2016-2023 Free Software Foundation, Inc. + Copyright 2016-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -99,6 +99,11 @@ # endif #endif +/* Assume no multibyte character is longer than 16 bytes. */ +#ifndef MB_LEN_MAX +# define MB_LEN_MAX 16 +#endif + /* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */ #if (! defined ULLONG_WIDTH \ @@ -119,11 +124,26 @@ /* Macros specified by C23. */ -#if (! defined BOOL_WIDTH \ - && (defined _GNU_SOURCE \ - || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))) -# define BOOL_MAX 1 -# define BOOL_WIDTH 1 +#if (defined _GNU_SOURCE \ + || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)) +# if ! defined BOOL_WIDTH +# define BOOL_WIDTH 1 +# define BOOL_MAX 1 +# elif ! defined BOOL_MAX +# define BOOL_MAX 1 +# endif +#endif + +/* Macro specified by POSIX. */ + +/* The maximum ssize_t value. Although it might not be of ssize_t type + as it should be, it's too much trouble to fix this minor detail. */ +#ifndef SSIZE_MAX +# ifdef _WIN64 +# define SSIZE_MAX LLONG_MAX +# else +# define SSIZE_MAX LONG_MAX +# endif #endif #endif /* _@GUARD_PREFIX@_LIMITS_H */ diff --git a/gl/localcharset.c b/gl/localcharset.c index 7ed9c95..93c4baa 100644 --- a/gl/localcharset.c +++ b/gl/localcharset.c @@ -1,6 +1,6 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2006, 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2000-2006, 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -1054,7 +1054,7 @@ locale_charset (void) } } if (0) - done_table_lookup: ; + done_table_lookup: {} else # endif { diff --git a/gl/localcharset.h b/gl/localcharset.h index 29ee8dc..4721402 100644 --- a/gl/localcharset.h +++ b/gl/localcharset.h @@ -1,5 +1,5 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2003, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2009-2024 Free Software Foundation, Inc. This file is part of the GNU CHARSET Library. This file is free software: you can redistribute it and/or modify @@ -104,10 +104,8 @@ extern const char * locale_charset (void); GBK glibc aix osf solaris freebsd darwin cygwin windows dos GB18030 glibc hpux solaris freebsd netbsd darwin SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin - JOHAB glibc solaris windows + JOHAB solaris windows TIS-620 glibc aix hpux osf solaris cygwin zos - VISCII Y glibc - TCVN5712-1 glibc ARMSCII-8 glibc freebsd netbsd darwin GEORGIAN-PS glibc cygwin PT154 glibc netbsd cygwin diff --git a/gl/locale.in.h b/gl/locale.in.h index 538b834..1b11a41 100644 --- a/gl/locale.in.h +++ b/gl/locale.in.h @@ -1,5 +1,5 @@ /* A POSIX . - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -44,6 +44,11 @@ #ifndef _@GUARD_PREFIX@_LOCALE_H #define _@GUARD_PREFIX@_LOCALE_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* NetBSD 5.0 mis-defines NULL. */ #include @@ -211,7 +216,7 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - " # include "setlocale_null.h" #endif -#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_NEWLOCALE@) +#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME_UNSAFE@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_NEWLOCALE@) # if @REPLACE_NEWLOCALE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef newlocale @@ -229,7 +234,7 @@ _GL_CXXALIAS_SYS (newlocale, locale_t, (int category_mask, const char *name, locale_t base)); # endif # endif -# if @HAVE_NEWLOCALE@ +# if __GLIBC__ >= 2 && @HAVE_NEWLOCALE@ _GL_CXXALIASWARN (newlocale); # endif # if @HAVE_NEWLOCALE@ || @REPLACE_NEWLOCALE@ @@ -244,24 +249,24 @@ _GL_WARN_ON_USE (newlocale, "newlocale is not portable"); # endif #endif -#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@) -# if @REPLACE_DUPLOCALE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef duplocale -# define duplocale rpl_duplocale -# define GNULIB_defined_duplocale 1 -# endif +#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME_UNSAFE@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@) +# if @HAVE_DUPLOCALE@ /* locale_t may be undefined if !@HAVE_DUPLOCALE@. */ +# if @REPLACE_DUPLOCALE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef duplocale +# define duplocale rpl_duplocale +# define GNULIB_defined_duplocale 1 +# endif _GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale)); -# else -# if @HAVE_DUPLOCALE@ +# else _GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale)); # endif # endif -# if @HAVE_DUPLOCALE@ +# if __GLIBC__ >= 2 && @HAVE_DUPLOCALE@ _GL_CXXALIASWARN (duplocale); # endif -# if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@ +# if @HAVE_DUPLOCALE@ # ifndef HAVE_WORKING_DUPLOCALE # define HAVE_WORKING_DUPLOCALE 1 # endif @@ -274,7 +279,7 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - " # endif #endif -#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_FREELOCALE@) +#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME_UNSAFE@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_FREELOCALE@) # if @REPLACE_FREELOCALE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef freelocale @@ -290,7 +295,7 @@ _GL_CXXALIAS_RPL (freelocale, void, (locale_t locale)); _GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale)); # endif # endif -# if @HAVE_FREELOCALE@ +# if __GLIBC__ >= 2 && @HAVE_FREELOCALE@ _GL_CXXALIASWARN (freelocale); # endif #elif defined GNULIB_POSIXCHECK diff --git a/gl/localeconv.c b/gl/localeconv.c index 60c050f..10fc7b7 100644 --- a/gl/localeconv.c +++ b/gl/localeconv.c @@ -1,5 +1,5 @@ /* Query locale dependent information for formatting numbers. - Copyright (C) 2012-2023 Free Software Foundation, Inc. + Copyright (C) 2012-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -19,10 +19,14 @@ /* Specification. */ #include +#include + #if HAVE_STRUCT_LCONV_DECIMAL_POINT +# define FIX_CHAR_VALUE(x) ((x) >= 0 ? (x) : CHAR_MAX) + /* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_* - members. */ + members or where fields of type 'char' are set to -1 instead of CHAR_MAX. */ struct lconv * localeconv (void) @@ -41,21 +45,30 @@ localeconv (void) result.positive_sign = sys_result->positive_sign; result.negative_sign = sys_result->negative_sign; result.currency_symbol = sys_result->currency_symbol; - result.frac_digits = sys_result->frac_digits; - result.p_cs_precedes = sys_result->p_cs_precedes; - result.p_sign_posn = sys_result->p_sign_posn; - result.p_sep_by_space = sys_result->p_sep_by_space; - result.n_cs_precedes = sys_result->n_cs_precedes; - result.n_sign_posn = sys_result->n_sign_posn; - result.n_sep_by_space = sys_result->n_sep_by_space; + result.frac_digits = FIX_CHAR_VALUE (sys_result->frac_digits); + result.p_cs_precedes = FIX_CHAR_VALUE (sys_result->p_cs_precedes); + result.p_sign_posn = FIX_CHAR_VALUE (sys_result->p_sign_posn); + result.p_sep_by_space = FIX_CHAR_VALUE (sys_result->p_sep_by_space); + result.n_cs_precedes = FIX_CHAR_VALUE (sys_result->n_cs_precedes); + result.n_sign_posn = FIX_CHAR_VALUE (sys_result->n_sign_posn); + result.n_sep_by_space = FIX_CHAR_VALUE (sys_result->n_sep_by_space); result.int_curr_symbol = sys_result->int_curr_symbol; - result.int_frac_digits = sys_result->int_frac_digits; - result.int_p_cs_precedes = sys_result->p_cs_precedes; - result.int_p_sign_posn = sys_result->p_sign_posn; - result.int_p_sep_by_space = sys_result->p_sep_by_space; - result.int_n_cs_precedes = sys_result->n_cs_precedes; - result.int_n_sign_posn = sys_result->n_sign_posn; - result.int_n_sep_by_space = sys_result->n_sep_by_space; + result.int_frac_digits = FIX_CHAR_VALUE (sys_result->int_frac_digits); +# if HAVE_STRUCT_LCONV_INT_P_CS_PRECEDES + result.int_p_cs_precedes = FIX_CHAR_VALUE (sys_result->int_p_cs_precedes); + result.int_p_sign_posn = FIX_CHAR_VALUE (sys_result->int_p_sign_posn); + result.int_p_sep_by_space = FIX_CHAR_VALUE (sys_result->int_p_sep_by_space); + result.int_n_cs_precedes = FIX_CHAR_VALUE (sys_result->int_n_cs_precedes); + result.int_n_sign_posn = FIX_CHAR_VALUE (sys_result->int_n_sign_posn); + result.int_n_sep_by_space = FIX_CHAR_VALUE (sys_result->int_n_sep_by_space); +# else + result.int_p_cs_precedes = FIX_CHAR_VALUE (sys_result->p_cs_precedes); + result.int_p_sign_posn = FIX_CHAR_VALUE (sys_result->p_sign_posn); + result.int_p_sep_by_space = FIX_CHAR_VALUE (sys_result->p_sep_by_space); + result.int_n_cs_precedes = FIX_CHAR_VALUE (sys_result->n_cs_precedes); + result.int_n_sign_posn = FIX_CHAR_VALUE (sys_result->n_sign_posn); + result.int_n_sep_by_space = FIX_CHAR_VALUE (sys_result->n_sep_by_space); +# endif return &result; } @@ -64,8 +77,6 @@ localeconv (void) /* Override for platforms where 'struct lconv' is a dummy. */ -# include - struct lconv * localeconv (void) { diff --git a/gl/lseek.c b/gl/lseek.c index 7919b03..61bd9fc 100644 --- a/gl/lseek.c +++ b/gl/lseek.c @@ -1,5 +1,5 @@ /* An lseek() function that detects pipes. - Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/m4/00gnulib.m4 b/gl/m4/00gnulib.m4 index 7fe03e0..cd16771 100644 --- a/gl/m4/00gnulib.m4 +++ b/gl/m4/00gnulib.m4 @@ -1,5 +1,6 @@ -# 00gnulib.m4 serial 8 -dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. +# 00gnulib.m4 +# serial 9 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -49,14 +50,14 @@ dnl AC_REQUIRE([gl_COMPILER_CLANG]) [if test $gl_cv_compiler_clang = yes; then dnl Test whether the compiler supports the option dnl '-Werror=implicit-function-declaration'. - save_ac_compile="$ac_compile" + saved_ac_compile="$ac_compile" ac_compile="$ac_compile -Werror=implicit-function-declaration" dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])], [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'], [gl_cv_compiler_check_decl_option=none]) - ac_compile="$save_ac_compile" + ac_compile="$saved_ac_compile" else gl_cv_compiler_check_decl_option=none fi @@ -71,11 +72,11 @@ dnl Redefine _AC_CHECK_DECL_BODY so that it references ac_compile_for_check_decl dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC dnl in zzgnulib.m4 is inactive, use the original ac_compile. m4_define([_AC_CHECK_DECL_BODY], -[ ac_save_ac_compile="$ac_compile" +[ ac_saved_ac_compile="$ac_compile" if test -n "$ac_compile_for_check_decl"; then ac_compile="$ac_compile_for_check_decl" fi] -m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_save_ac_compile" +m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_saved_ac_compile" ]) # gl_00GNULIB diff --git a/gl/m4/__inline.m4 b/gl/m4/__inline.m4 index acf8668..20baf16 100644 --- a/gl/m4/__inline.m4 +++ b/gl/m4/__inline.m4 @@ -1,9 +1,12 @@ -# Test for __inline keyword -dnl Copyright 2017-2023 Free Software Foundation, Inc. +# __inline.m4 +# serial 1 +dnl Copyright 2017-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +# Test for __inline keyword + AC_DEFUN([gl___INLINE], [ AC_CACHE_CHECK([whether the compiler supports the __inline keyword], diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4 index e794764..0abd6d9 100644 --- a/gl/m4/absolute-header.m4 +++ b/gl/m4/absolute-header.m4 @@ -1,5 +1,6 @@ -# absolute-header.m4 serial 17 -dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. +# absolute-header.m4 +# serial 18 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -66,7 +67,7 @@ AC_DEFUN([gl_ABSOLUTE_HEADER_ONE], esac changequote(,) case "$host_os" in - mingw*) + mingw* | windows*) dnl For the sake of native Windows compilers (excluding gcc), dnl treat backslash as a directory separator, like /. dnl Actually, these compilers use a double-backslash as diff --git a/gl/m4/af_alg.m4 b/gl/m4/af_alg.m4 index f4c0d62..33b7494 100644 --- a/gl/m4/af_alg.m4 +++ b/gl/m4/af_alg.m4 @@ -1,5 +1,6 @@ -# af_alg.m4 serial 6 -dnl Copyright 2018-2023 Free Software Foundation, Inc. +# af_alg.m4 +# serial 6 +dnl Copyright 2018-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4 index c685fac..dc78dc1 100644 --- a/gl/m4/alloca.m4 +++ b/gl/m4/alloca.m4 @@ -1,5 +1,6 @@ -# alloca.m4 serial 21 -dnl Copyright (C) 2002-2004, 2006-2007, 2009-2023 Free Software Foundation, +# alloca.m4 +# serial 21 +dnl Copyright (C) 2002-2004, 2006-2007, 2009-2024 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/arpa_inet_h.m4 b/gl/m4/arpa_inet_h.m4 index fa5fe83..9eac86d 100644 --- a/gl/m4/arpa_inet_h.m4 +++ b/gl/m4/arpa_inet_h.m4 @@ -1,5 +1,6 @@ -# arpa_inet_h.m4 serial 17 -dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc. +# arpa_inet_h.m4 +# serial 17 +dnl Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/assert_h.m4 b/gl/m4/assert_h.m4 index abba4fa..b90d0f1 100644 --- a/gl/m4/assert_h.m4 +++ b/gl/m4/assert_h.m4 @@ -1,5 +1,6 @@ -# assert-h.m4 -dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. +# assert_h.m4 +# serial 1 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -9,16 +10,16 @@ dnl From Paul Eggert. AC_DEFUN([gl_ASSERT_H], [ AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert], - [gl_save_CFLAGS=$CFLAGS + [gl_saved_CFLAGS=$CFLAGS for gl_working in "yes, a keyword" "yes, an macro"; do AS_CASE([$gl_working], - [*assert.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_ASSERT_H"]) + [*assert.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_ASSERT_H"]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[#if defined __clang__ && __STDC_VERSION__ < 202311 #pragma clang diagnostic error "-Wc2x-extensions" - #pragma clang diagnostic error "-Wc++17-extensions" + #pragma clang diagnostic error "-Wc++1z-extensions" #endif #ifdef INCLUDE_ASSERT_H #include @@ -32,7 +33,7 @@ AC_DEFUN([gl_ASSERT_H], ]])], [gl_cv_static_assert=$gl_working], [gl_cv_static_assert=no]) - CFLAGS=$gl_save_CFLAGS + CFLAGS=$gl_saved_CFLAGS test "$gl_cv_static_assert" != no && break done]) @@ -46,10 +47,13 @@ AC_DEFUN([gl_ASSERT_H], gl_NEXT_HEADERS([assert.h])]) dnl The "zz" puts this toward config.h's end, to avoid potential - dnl collisions with other definitions. #undef assert so that - dnl programs are not tempted to use it without specifically - dnl including assert.h. Break the #undef apart with a comment - dnl so that 'configure' does not comment it out. + dnl collisions with other definitions. + dnl #undef assert so that programs are not tempted to use it without + dnl specifically including assert.h. + dnl #undef __ASSERT_H__ so that on IRIX, when programs later include + dnl , this include actually defines assert. + dnl Break the #undef_s apart with a comment so that 'configure' does + dnl not comment them out. AH_VERBATIM([zzstatic_assert], [#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \ && (!defined __cplusplus \ @@ -57,6 +61,9 @@ AC_DEFUN([gl_ASSERT_H], && __GNUG__ < 6 && __clang_major__ < 6))) #include #undef/**/assert + #ifdef __sgi + #undef/**/__ASSERT_H__ + #endif /* Solaris 11.4 defines static_assert as a macro with 2 arguments. We need it also to be invocable with a single argument. */ #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus diff --git a/gl/m4/base64.m4 b/gl/m4/base64.m4 index 987930a..26f2af4 100644 --- a/gl/m4/base64.m4 +++ b/gl/m4/base64.m4 @@ -1,5 +1,6 @@ -# base64.m4 serial 4 -dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc. +# base64.m4 +# serial 4 +dnl Copyright (C) 2004, 2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4 index 77218a7..d9dd703 100644 --- a/gl/m4/btowc.m4 +++ b/gl/m4/btowc.m4 @@ -1,5 +1,6 @@ -# btowc.m4 serial 12 -dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. +# btowc.m4 +# serial 14 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -40,12 +41,12 @@ int main () [ changequote(,)dnl case "$host_os" in - # Guess no on Cygwin. - cygwin*) gl_cv_func_btowc_nul="guessing no" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_btowc_nul="guessing yes" ;; - # Guess yes otherwise. - *) gl_cv_func_btowc_nul="guessing yes" ;; + # Guess no on Cygwin. + cygwin*) gl_cv_func_btowc_nul="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_btowc_nul="guessing yes" ;; + # Guess yes otherwise. + *) gl_cv_func_btowc_nul="guessing yes" ;; esac changequote([,])dnl ]) @@ -59,12 +60,12 @@ changequote([,])dnl dnl is present. changequote(,)dnl case "$host_os" in - # Guess no on IRIX. - irix*) gl_cv_func_btowc_eof="guessing no" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_btowc_eof="guessing yes" ;; - # Guess yes otherwise. - *) gl_cv_func_btowc_eof="guessing yes" ;; + # Guess no on IRIX. + irix*) gl_cv_func_btowc_eof="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_btowc_eof="guessing yes" ;; + # Guess yes otherwise. + *) gl_cv_func_btowc_eof="guessing yes" ;; esac changequote([,])dnl if test $LOCALE_FR != none; then @@ -88,6 +89,50 @@ int main () fi ]) + dnl On mingw, in the C locale, btowc is inconsistent with mbrtowc: + dnl mbrtowc avoids calling MultiByteToWideChar when MB_CUR_MAX is 1 and + dnl ___lc_codepage_func() is 0, but btowc is lacking this special case. + AC_CHECK_FUNCS_ONCE([mbrtowc]) + AC_CACHE_CHECK([whether btowc is consistent with mbrtowc in the C locale], + [gl_cv_func_btowc_consistent], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ +#if HAVE_MBRTOWC + wint_t wc1 = btowc (0x80); + wchar_t wc2 = (wchar_t) 0xbadface; + char buf[1] = { 0x80 }; + mbstate_t state; + memset (&state, 0, sizeof (mbstate_t)); + if (mbrtowc (&wc2, buf, 1, &state) != 1 || wc1 != wc2) + return 1; +#endif + return 0; +}]])], + [gl_cv_func_btowc_consistent=yes], + [gl_cv_func_btowc_consistent=no], + [case "$host_os" in + # Guess no on mingw. + mingw* | windows*) + AC_EGREP_CPP([Problem], [ +#ifdef __MINGW32__ + Problem +#endif + ], + [gl_cv_func_btowc_consistent="guessing no"], + [gl_cv_func_btowc_consistent="guessing yes"]) + ;; + # Guess yes otherwise. + *) gl_cv_func_btowc_consistent="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_btowc_nul" in *yes) ;; *) REPLACE_BTOWC=1 ;; @@ -96,10 +141,22 @@ int main () *yes) ;; *) REPLACE_BTOWC=1 ;; esac + case "$gl_cv_func_btowc_consistent" in + *yes) ;; + *) REPLACE_BTOWC=1 ;; + esac + if test $REPLACE_BTOWC = 0; then + gl_MBRTOWC_C_LOCALE + case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in + *yes) ;; + *) REPLACE_BTOWC=1 ;; + esac + fi fi ]) # Prerequisites of lib/btowc.c. AC_DEFUN([gl_PREREQ_BTOWC], [ : + AC_CHECK_FUNCS_ONCE([mbrtowc]) ]) diff --git a/gl/m4/builtin-expect.m4 b/gl/m4/builtin-expect.m4 index 531ed48..c7af926 100644 --- a/gl/m4/builtin-expect.m4 +++ b/gl/m4/builtin-expect.m4 @@ -1,10 +1,12 @@ -dnl Check for __builtin_expect. - -dnl Copyright 2016-2023 Free Software Foundation, Inc. +# builtin-expect.m4 +# serial 1 +dnl Copyright 2016-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl Check for __builtin_expect. + dnl Written by Paul Eggert. AC_DEFUN([gl___BUILTIN_EXPECT], diff --git a/gl/m4/byteswap.m4 b/gl/m4/byteswap.m4 index 8058d17..0c76fe9 100644 --- a/gl/m4/byteswap.m4 +++ b/gl/m4/byteswap.m4 @@ -1,5 +1,6 @@ -# byteswap.m4 serial 5 -dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc. +# byteswap.m4 +# serial 5 +dnl Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/c-bool.m4 b/gl/m4/c-bool.m4 index f614371..0fb0de3 100644 --- a/gl/m4/c-bool.m4 +++ b/gl/m4/c-bool.m4 @@ -1,10 +1,12 @@ -# Check for bool that conforms to C2023. - -dnl Copyright 2022-2023 Free Software Foundation, Inc. +# c-bool.m4 +# serial 1 +dnl Copyright 2022-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +# Check for bool that conforms to C2023. + AC_DEFUN([gl_C_BOOL], [ AC_CACHE_CHECK([for bool, true, false], [gl_cv_c_bool], diff --git a/gl/m4/calloc.m4 b/gl/m4/calloc.m4 index 23c0dd9..550cf5c 100644 --- a/gl/m4/calloc.m4 +++ b/gl/m4/calloc.m4 @@ -1,9 +1,9 @@ -# calloc.m4 serial 29 - -# Copyright (C) 2004-2023 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# calloc.m4 +# serial 31 +dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. # Written by Jim Meyering. @@ -36,14 +36,14 @@ AC_DEFUN([_AC_FUNC_CALLOC_IF], [ac_cv_func_calloc_0_nonnull=no]) else case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; - # Guess yes on musl systems. - *-musl*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; - # Guess yes on native Windows. - mingw*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) ac_cv_func_calloc_0_nonnull="$gl_cross_guess_normal" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) ac_cv_func_calloc_0_nonnull="$gl_cross_guess_normal" ;; esac fi ]) diff --git a/gl/m4/close.m4 b/gl/m4/close.m4 index 9f95c67..88c37fa 100644 --- a/gl/m4/close.m4 +++ b/gl/m4/close.m4 @@ -1,10 +1,11 @@ -# close.m4 serial 9 -dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. +# close.m4 +# serial 10 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -AC_DEFUN([gl_FUNC_CLOSE], +AC_DEFUN_ONCE([gl_FUNC_CLOSE], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) m4_ifdef([gl_MSVC_INVAL], [ diff --git a/gl/m4/codeset.m4 b/gl/m4/codeset.m4 index 5804f47..e69b740 100644 --- a/gl/m4/codeset.m4 +++ b/gl/m4/codeset.m4 @@ -1,5 +1,6 @@ -# codeset.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2023 Free Software +# codeset.m4 +# serial 5 (gettext-0.18.2) +dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2024 Free Software dnl Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/double-slash-root.m4 b/gl/m4/double-slash-root.m4 index 1776e5e..3437c69 100644 --- a/gl/m4/double-slash-root.m4 +++ b/gl/m4/double-slash-root.m4 @@ -1,5 +1,6 @@ -# double-slash-root.m4 serial 4 -*- Autoconf -*- -dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc. +# double-slash-root.m4 +# serial 4 -*- Autoconf -*- +dnl Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/dup2.m4 b/gl/m4/dup2.m4 index e1cc73e..786121f 100644 --- a/gl/m4/dup2.m4 +++ b/gl/m4/dup2.m4 @@ -1,5 +1,6 @@ -#serial 27 -dnl Copyright (C) 2002, 2005, 2007, 2009-2023 Free Software Foundation, Inc. +# dup2.m4 +# serial 28 +dnl Copyright (C) 2002, 2005, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -67,7 +68,7 @@ AC_DEFUN([gl_FUNC_DUP2], ], [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no], [case "$host_os" in - mingw*) # on this platform, dup2 always returns 0 for success + mingw* | windows*) # on this platform, dup2 always returns 0 for success gl_cv_func_dup2_works="guessing no" ;; cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0 gl_cv_func_dup2_works="guessing no" ;; diff --git a/gl/m4/eealloc.m4 b/gl/m4/eealloc.m4 index cb3e08f..8a15e70 100644 --- a/gl/m4/eealloc.m4 +++ b/gl/m4/eealloc.m4 @@ -1,5 +1,6 @@ -# eealloc.m4 serial 3 -dnl Copyright (C) 2003, 2009-2023 Free Software Foundation, Inc. +# eealloc.m4 +# serial 3 +dnl Copyright (C) 2003, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4 index 741dfc5..107960b 100644 --- a/gl/m4/environ.m4 +++ b/gl/m4/environ.m4 @@ -1,5 +1,6 @@ -# environ.m4 serial 8 -dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc. +# environ.m4 +# serial 8 +dnl Copyright (C) 2001-2004, 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4 index 4c70d22..b6050e5 100644 --- a/gl/m4/errno_h.m4 +++ b/gl/m4/errno_h.m4 @@ -1,5 +1,6 @@ -# errno_h.m4 serial 14 -dnl Copyright (C) 2004, 2006, 2008-2023 Free Software Foundation, Inc. +# errno_h.m4 +# serial 14 +dnl Copyright (C) 2004, 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/error.m4 b/gl/m4/error.m4 index 8cc75df..273b636 100644 --- a/gl/m4/error.m4 +++ b/gl/m4/error.m4 @@ -1,22 +1,12 @@ -#serial 15 - -# Copyright (C) 1996-1998, 2001-2004, 2009-2023 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# error.m4 +# serial 16 +dnl Copyright (C) 1996-1998, 2001-2004, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_ERROR], [ - dnl We don't use AC_FUNC_ERROR_AT_LINE any more, because it is no longer - dnl maintained in Autoconf and because it invokes AC_LIBOBJ. - AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[error_at_line (0, 0, "", 0, "an error occurred");]])], - [ac_cv_lib_error_at_line=yes], - [ac_cv_lib_error_at_line=no])]) ]) # Prerequisites of lib/error.c. diff --git a/gl/m4/error_h.m4 b/gl/m4/error_h.m4 new file mode 100644 index 0000000..050a410 --- /dev/null +++ b/gl/m4/error_h.m4 @@ -0,0 +1,125 @@ +# error_h.m4 +# serial 4 +dnl Copyright (C) 1996-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Provide a working . + +AC_DEFUN_ONCE([gl_ERROR_H], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + gl_CHECK_NEXT_HEADERS([error.h]) + if test $ac_cv_header_error_h = yes; then + HAVE_ERROR_H=1 + else + HAVE_ERROR_H=0 + fi + AC_SUBST([HAVE_ERROR_H]) + + REPLACE_ERROR=0 + + gl_CHECK_FUNCS_ANDROID([error], [[#include ]]) + if test $ac_cv_func_error = yes; then + HAVE_ERROR=1 + else + HAVE_ERROR=0 + case "$gl_cv_onwards_func_error" in + future*) REPLACE_ERROR=1 ;; + esac + fi + + dnl We don't use AC_FUNC_ERROR_AT_LINE any more, because it is no longer + dnl maintained in Autoconf and because it invokes AC_LIBOBJ. + dnl We need to notice a missing declaration, like gl_CHECK_FUNCS_ANDROID does. + AC_CHECK_DECL([error_at_line], , , [[#include ]]) + if test $ac_cv_have_decl_error_at_line = yes; then + AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[error_at_line (0, 0, "", 0, "an error occurred");]])], + [ac_cv_lib_error_at_line=yes], + [ac_cv_lib_error_at_line=no])]) + else + ac_cv_lib_error_at_line=no + fi + if test $ac_cv_lib_error_at_line = yes; then + HAVE_ERROR_AT_LINE=1 + else + HAVE_ERROR_AT_LINE=0 + fi + REPLACE_ERROR_AT_LINE=0 + + if test $ac_cv_func_error = yes && test $ac_cv_lib_error_at_line = yes; then + dnl On Android 11, when error_print_progname is set, the output of the + dnl error() function contains an extra space. + AC_CACHE_CHECK([for working error function], + [gl_cv_func_working_error], + [if test $cross_compiling != yes; then + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ + #include + static void print_no_progname (void) {} + ]], [[ + error_print_progname = print_no_progname; + error (0, 0, "foo"); + ]]) + ], + [rm -f conftest.out + if test -s conftest$ac_exeext \ + && ./conftest$ac_exeext 2> conftest.out; then + if grep ' ' conftest.out >/dev/null; then + gl_cv_func_working_error=no + else + gl_cv_func_working_error=yes + fi + else + gl_cv_func_working_error=no + fi + rm -f conftest.out + ], + [gl_cv_func_working_error=no]) + else + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include + ]], [[ + error (0, 0, "foo"); + ]]) + ], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_working_error="guessing yes" ;; + # Guess no on Android. + linux*-android*) gl_cv_func_working_error="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_working_error="$gl_cross_guess_normal" ;; + esac + ], + [gl_cv_func_working_error=no]) + fi + ]) + case "$gl_cv_func_working_error" in + *no) + REPLACE_ERROR=1 + REPLACE_ERROR_AT_LINE=1 + ;; + esac + fi + + if test $HAVE_ERROR = 0 || test $REPLACE_ERROR = 1 \ + || test $HAVE_ERROR_AT_LINE = 0 || test $REPLACE_ERROR_AT_LINE = 1; then + COMPILE_ERROR_C=1 + else + COMPILE_ERROR_C=0 + fi + + AC_SUBST([HAVE_ERROR]) + AC_SUBST([HAVE_ERROR_AT_LINE]) + AC_SUBST([REPLACE_ERROR]) + AC_SUBST([REPLACE_ERROR_AT_LINE]) +]) diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4 index 2ef4643..db597af 100644 --- a/gl/m4/exponentd.m4 +++ b/gl/m4/exponentd.m4 @@ -1,9 +1,10 @@ -# exponentd.m4 serial 3 -dnl Copyright (C) 2007-2008, 2010-2023 Free Software Foundation, Inc. +# exponentd.m4 +# serial 4 +dnl Copyright (C) 2007-2008, 2010-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -AC_DEFUN([gl_DOUBLE_EXPONENT_LOCATION], +AC_DEFUN_ONCE([gl_DOUBLE_EXPONENT_LOCATION], [ AC_CACHE_CHECK([where to find the exponent in a 'double'], [gl_cv_cc_double_expbit0], diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4 index 5336b8d..1fb6895 100644 --- a/gl/m4/extensions.m4 +++ b/gl/m4/extensions.m4 @@ -1,10 +1,11 @@ -# serial 23 -*- Autoconf -*- -# Enable extensions on systems that normally disable them. +# extensions.m4 +# serial 25 -*- Autoconf -*- +dnl Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -# Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# Enable extensions on systems that normally disable them. dnl Define to empty for the benefit of Autoconf 2.69 and earlier, so that dnl AC_USE_SYSTEM_EXTENSIONS (below) can be used unchanged from Autoconf 2.70+. @@ -229,4 +230,15 @@ AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], [Define to enable the declarations of ISO C 11 types and functions.]) ;; esac + + dnl On OpenSolaris derivatives, the include files contains a couple of + dnl declarations that are only activated with an explicit + dnl -D__STDC_WANT_LIB_EXT1__. + AH_VERBATIM([USE_ISO_C_23_ANNEX_K_EXTENSIONS], +[/* Define to enable the declarations of ISO C 23 Annex K types and functions. */ +#if !(defined __STDC_WANT_LIB_EXT1__ && __STDC_WANT_LIB_EXT1__) +#undef/**/__STDC_WANT_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 +#endif +]) ]) diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4 index c001b1c..547da82 100644 --- a/gl/m4/extern-inline.m4 +++ b/gl/m4/extern-inline.m4 @@ -1,10 +1,12 @@ -dnl 'extern inline' a la ISO C99. - -dnl Copyright 2012-2023 Free Software Foundation, Inc. +# extern-inline.m4 +# serial 1 +dnl Copyright 2012-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl 'extern inline' a la ISO C99. + AC_DEFUN([gl_EXTERN_INLINE], [ AC_CACHE_CHECK([whether ctype.h defines __header_inline], @@ -79,7 +81,8 @@ AC_DEFUN([gl_EXTERN_INLINE], # define _GL_EXTERN_INLINE_STDHEADER_BUG #endif #if ((__GNUC__ \ - ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ + ? (defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ + && !defined __PCC__) \ : (199901L <= __STDC_VERSION__ \ && !defined __HP_cc \ && !defined __PGI \ @@ -89,6 +92,7 @@ AC_DEFUN([gl_EXTERN_INLINE], # define _GL_EXTERN_INLINE extern inline # define _GL_EXTERN_INLINE_IN_USE #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ + && !defined __PCC__ \ && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) # if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ diff --git a/gl/m4/fclose.m4 b/gl/m4/fclose.m4 new file mode 100644 index 0000000..0c1358e --- /dev/null +++ b/gl/m4/fclose.m4 @@ -0,0 +1,99 @@ +# fclose.m4 +# serial 12 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_FUNC_FCLOSE], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + gl_FUNC_FFLUSH_STDIN + case "$gl_cv_func_fflush_stdin" in + *yes) ;; + *) REPLACE_FCLOSE=1 ;; + esac + + AC_REQUIRE([gl_FUNC_CLOSE]) + if test $REPLACE_CLOSE = 1; then + REPLACE_FCLOSE=1 + fi + + case "$host_os" in + openedition) REPLACE_FCLOSE=1 ;; + esac + + if test $REPLACE_FCLOSE = 0; then + gl_FUNC_FCLOSE_STDIN + case "$gl_cv_func_fclose_stdin" in + *yes) ;; + *) REPLACE_FCLOSE=1 ;; + esac + fi +]) + +dnl Determine whether fclose works on input streams. +dnl Sets gl_cv_func_fclose_stdin. + +AC_DEFUN([gl_FUNC_FCLOSE_STDIN], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CACHE_CHECK([whether fclose works on input streams], + [gl_cv_func_fclose_stdin], + [echo hello world > conftest.txt + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #if HAVE_UNISTD_H + # include + #else /* on Windows with MSVC */ + # include + #endif + ]GL_MDA_DEFINES], + [[int fd; + int fd2; + FILE *fp; + fd = open ("conftest.txt", O_RDONLY); + if (fd < 0) + return 1; + if (lseek (fd, 1, SEEK_SET) != 1) + return 2; + fd2 = dup (fd); + if (fd2 < 0) + return 3; + fp = fdopen (fd2, "r"); + if (fp == NULL) + return 4; + if (fgetc (fp) != 'e') + { fclose (fp); return 5; } + /* This fclose() call should reposition the underlying file + descriptor. */ + if (fclose (fp) != 0) + return 6; + if (lseek (fd2, 0, SEEK_CUR) != -1) /* should fail with EBADF */ + return 7; + /* Verify the file position. */ + if (lseek (fd, 0, SEEK_CUR) != 2) + return 8; + return 0; + ]])], + [gl_cv_func_fclose_stdin=yes], + [gl_cv_func_fclose_stdin=no], + [case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_fclose_stdin="guessing no" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_fclose_stdin="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_fclose_stdin="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_fclose_stdin="$gl_cross_guess_normal" ;; + esac + ]) + rm conftest.txt + ]) +]) diff --git a/gl/m4/fcntl-o.m4 b/gl/m4/fcntl-o.m4 index 59d558b..43aa132 100644 --- a/gl/m4/fcntl-o.m4 +++ b/gl/m4/fcntl-o.m4 @@ -1,5 +1,6 @@ -# fcntl-o.m4 serial 7 -dnl Copyright (C) 2006, 2009-2023 Free Software Foundation, Inc. +# fcntl-o.m4 +# serial 8 +dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -117,9 +118,9 @@ AC_DEFUN([gl_FCNTL_O_FLAGS], *) gl_cv_header_working_fcntl_h='no';; esac], [case "$host_os" in - # Guess 'no' on native Windows. - mingw*) gl_cv_header_working_fcntl_h='no' ;; - *) gl_cv_header_working_fcntl_h=cross-compiling ;; + # Guess 'no' on native Windows. + mingw* | windows*) gl_cv_header_working_fcntl_h='no' ;; + *) gl_cv_header_working_fcntl_h=cross-compiling ;; esac ]) ]) diff --git a/gl/m4/fcntl.m4 b/gl/m4/fcntl.m4 index 524a99a..f6d0f37 100644 --- a/gl/m4/fcntl.m4 +++ b/gl/m4/fcntl.m4 @@ -1,5 +1,6 @@ -# fcntl.m4 serial 11 -dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. +# fcntl.m4 +# serial 12 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -82,7 +83,7 @@ AC_DEFUN([gl_FUNC_FCNTL], esac dnl Many systems lack F_DUPFD_CLOEXEC. - dnl NetBSD 9.0 declares F_DUPFD_CLOEXEC but it works only like F_DUPFD. + dnl NetBSD 10.0 declares F_DUPFD_CLOEXEC but it works only like F_DUPFD. AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC], [gl_cv_func_fcntl_f_dupfd_cloexec], [AC_RUN_IFELSE( diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4 index 68f4e64..b69f7a0 100644 --- a/gl/m4/fcntl_h.m4 +++ b/gl/m4/fcntl_h.m4 @@ -1,10 +1,12 @@ +# fcntl_h.m4 # serial 20 -# Configure fcntl.h. -dnl Copyright (C) 2006-2007, 2009-2023 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +# Configure fcntl.h. + dnl Written by Paul Eggert. AC_DEFUN_ONCE([gl_FCNTL_H], diff --git a/gl/m4/fflush.m4 b/gl/m4/fflush.m4 index 3e3c890..43fc3bf 100644 --- a/gl/m4/fflush.m4 +++ b/gl/m4/fflush.m4 @@ -1,9 +1,9 @@ -# fflush.m4 serial 18 - -# Copyright (C) 2007-2023 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# fflush.m4 +# serial 19 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. dnl From Eric Blake @@ -79,9 +79,9 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no], [case "$host_os" in - # Guess no on native Windows. - mingw*) gl_cv_func_fflush_stdin="guessing no" ;; - *) gl_cv_func_fflush_stdin=cross ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_fflush_stdin="guessing no" ;; + *) gl_cv_func_fflush_stdin=cross ;; esac ]) rm conftest.txt diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4 index 2f0c9c4..c95d417 100644 --- a/gl/m4/float_h.m4 +++ b/gl/m4/float_h.m4 @@ -1,5 +1,6 @@ -# float_h.m4 serial 13 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# float_h.m4 +# serial 14 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -84,9 +85,11 @@ int main () [gl_cv_func_itold_works="guessing no"], [gl_cv_func_itold_works="guessing yes"]) ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_itold_works="guessing yes" ;; - *) gl_cv_func_itold_works="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) + gl_cv_func_itold_works="guessing yes" ;; + *) + gl_cv_func_itold_works="guessing yes" ;; esac ]) ]) diff --git a/gl/m4/floorf.m4 b/gl/m4/floorf.m4 index c49ffa6..2572c84 100644 --- a/gl/m4/floorf.m4 +++ b/gl/m4/floorf.m4 @@ -1,5 +1,6 @@ -# floorf.m4 serial 18 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# floorf.m4 +# serial 21 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -26,7 +27,7 @@ AC_DEFUN([gl_FUNC_FLOORF], AC_CACHE_CHECK([whether floorf works according to ISO C 99 with IEC 60559], [gl_cv_func_floorf_ieee], [ - save_LIBS="$LIBS" + saved_LIBS="$LIBS" LIBS="$LIBS $FLOORF_LIBM" AC_RUN_IFELSE( [AC_LANG_SOURCE([[ @@ -49,17 +50,17 @@ int main (int argc, char *argv[]) [gl_cv_func_floorf_ieee=yes], [gl_cv_func_floorf_ieee=no], [case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_floorf_ieee="guessing yes" ;; - # Guess yes on musl systems. - *-musl*) gl_cv_func_floorf_ieee="guessing yes" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_floorf_ieee="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_floorf_ieee="$gl_cross_guess_normal" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_floorf_ieee="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_floorf_ieee="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_floorf_ieee="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_floorf_ieee="$gl_cross_guess_normal" ;; esac ]) - LIBS="$save_LIBS" + LIBS="$saved_LIBS" ]) case "$gl_cv_func_floorf_ieee" in *yes) ;; @@ -94,7 +95,7 @@ AC_DEFUN([gl_FUNC_FLOORF_LIBS], [[x = funcptr(x) + floorf(x);]])], [gl_cv_func_floorf_libm=]) if test "$gl_cv_func_floorf_libm" = "?"; then - save_LIBS="$LIBS" + saved_LIBS="$LIBS" LIBS="$LIBS -lm" AC_LINK_IFELSE( [AC_LANG_PROGRAM( @@ -106,7 +107,7 @@ AC_DEFUN([gl_FUNC_FLOORF_LIBS], float x;]], [[x = funcptr(x) + floorf(x);]])], [gl_cv_func_floorf_libm="-lm"]) - LIBS="$save_LIBS" + LIBS="$saved_LIBS" fi ]) FLOORF_LIBM="$gl_cv_func_floorf_libm" diff --git a/gl/m4/fopen.m4 b/gl/m4/fopen.m4 index 9c39ff7..f3b7aad 100644 --- a/gl/m4/fopen.m4 +++ b/gl/m4/fopen.m4 @@ -1,15 +1,16 @@ -# fopen.m4 serial 13 -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# fopen.m4 +# serial 16 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -AC_DEFUN([gl_FUNC_FOPEN], +AC_DEFUN([gl_FUNC_FOPEN_ITSELF], [ AC_REQUIRE([gl_STDIO_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) case "$host_os" in - mingw* | pw*) + mingw* | windows* | pw*) dnl Replace fopen, for handling of "/dev/null". REPLACE_FOPEN=1 dnl fopen on mingw also has the trailing slash bug. @@ -58,6 +59,15 @@ changequote([,])dnl esac ]) +AC_DEFUN([gl_FUNC_FOPEN], +[ + AC_REQUIRE([gl_FUNC_FOPEN_ITSELF]) + AC_REQUIRE([gl_FUNC_FCLOSE]) + if test $REPLACE_FCLOSE = 1; then + REPLACE_FOPEN=1 + fi +]) + AC_DEFUN([gl_FUNC_FOPEN_GNU], [ AC_REQUIRE([gl_FUNC_FOPEN]) @@ -87,7 +97,7 @@ int main () [gl_cv_func_fopen_mode_x=no], [case "$host_os" in # Guess yes on glibc and musl systems. - linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*) + linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl* | midipix*) gl_cv_func_fopen_mode_x="guessing yes" ;; # If we don't know, obey --enable-cross-guesses. *) @@ -124,10 +134,10 @@ int main () [gl_cv_func_fopen_mode_e=no], [case "$host_os" in # Guess yes on glibc and musl systems. - linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*) + linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl* | midipix*) gl_cv_func_fopen_mode_e="guessing yes" ;; # Guess no on native Windows. - mingw*) + mingw* | windows*) gl_cv_func_fopen_mode_e="guessing no" ;; # If we don't know, obey --enable-cross-guesses. *) diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4 index b365409..a77f5b9 100644 --- a/gl/m4/fpurge.m4 +++ b/gl/m4/fpurge.m4 @@ -1,5 +1,6 @@ -# fpurge.m4 serial 12 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# fpurge.m4 +# serial 14 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -10,7 +11,7 @@ AC_DEFUN([gl_FUNC_FPURGE], AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CHECK_HEADERS_ONCE([stdio_ext.h]) AC_CHECK_FUNCS_ONCE([fpurge]) - AC_CHECK_FUNCS_ONCE([__fpurge]) + gl_CHECK_FUNCS_ANDROID([__fpurge], [[#include ]]) AC_CHECK_DECLS([fpurge], , , [[#include ]]) if test "x$ac_cv_func_fpurge" = xyes; then HAVE_FPURGE=1 @@ -53,10 +54,10 @@ AC_DEFUN([gl_FUNC_FPURGE], [gl_cv_func_fpurge_works=yes], [gl_cv_func_fpurge_works=no], [case "$host_os" in - # Guess yes on musl systems. - *-musl*) gl_cv_func_fpurge_works="guessing yes" ;; - # Otherwise obey --enable-cross-guesses. - *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_fpurge_works="guessing yes" ;; + # Otherwise obey --enable-cross-guesses. + *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;; esac ]) ]) diff --git a/gl/m4/freading.m4 b/gl/m4/freading.m4 index 3533336..be89945 100644 --- a/gl/m4/freading.m4 +++ b/gl/m4/freading.m4 @@ -1,5 +1,6 @@ -# freading.m4 serial 2 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# freading.m4 +# serial 3 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -7,5 +8,8 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_FREADING], [ AC_CHECK_HEADERS_ONCE([stdio_ext.h]) - AC_CHECK_FUNCS_ONCE([__freading]) + gl_CHECK_FUNCS_ANDROID([__freading], + [[#include + #include + ]]) ]) diff --git a/gl/m4/free.m4 b/gl/m4/free.m4 index 0389dea..a2b596d 100644 --- a/gl/m4/free.m4 +++ b/gl/m4/free.m4 @@ -1,8 +1,9 @@ -# free.m4 serial 6 -# Copyright (C) 2003-2005, 2009-2023 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# free.m4 +# serial 6 +dnl Copyright (C) 2003-2005, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. # Written by Paul Eggert and Bruno Haible. diff --git a/gl/m4/fseek.m4 b/gl/m4/fseek.m4 index c5fe688..fb220a1 100644 --- a/gl/m4/fseek.m4 +++ b/gl/m4/fseek.m4 @@ -1,5 +1,6 @@ -# fseek.m4 serial 4 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# fseek.m4 +# serial 4 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4 index 05ee06b..5682a1f 100644 --- a/gl/m4/fseeko.m4 +++ b/gl/m4/fseeko.m4 @@ -1,5 +1,6 @@ -# fseeko.m4 serial 20 -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# fseeko.m4 +# serial 20 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/fstat.m4 b/gl/m4/fstat.m4 index 7cb2edb..47777b0 100644 --- a/gl/m4/fstat.m4 +++ b/gl/m4/fstat.m4 @@ -1,5 +1,6 @@ -# fstat.m4 serial 8 -dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. +# fstat.m4 +# serial 10 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -10,10 +11,10 @@ AC_DEFUN([gl_FUNC_FSTAT], AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) case "$host_os" in - mingw* | solaris*) + darwin* | mingw* | windows* | solaris*) + dnl macOS and Solaris stat can return a negative tv_nsec. dnl On MinGW, the original stat() returns st_atime, st_mtime, dnl st_ctime values that are affected by the time zone. - dnl Solaris stat can return a negative tv_nsec. REPLACE_FSTAT=1 ;; esac diff --git a/gl/m4/fstypename.m4 b/gl/m4/fstypename.m4 index f65c459..05a6880 100644 --- a/gl/m4/fstypename.m4 +++ b/gl/m4/fstypename.m4 @@ -1,4 +1,10 @@ -#serial 6 +# fstypename.m4 +# serial 6 +dnl Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2024 Free Software +dnl Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. dnl From Jim Meyering. dnl @@ -6,12 +12,6 @@ dnl See if struct statfs has the f_fstypename member. dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME. dnl -# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2023 Free Software -# Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - AC_DEFUN([gl_FSTYPENAME], [ AC_CHECK_MEMBERS([struct statfs.f_fstypename],,, diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4 index 88f3ca8..1ce9066 100644 --- a/gl/m4/fsusage.m4 +++ b/gl/m4/fsusage.m4 @@ -1,11 +1,11 @@ +# fsusage.m4 # serial 35 -# Obtaining file system usage information. +dnl Copyright (C) 1997-1998, 2000-2001, 2003-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -# Copyright (C) 1997-1998, 2000-2001, 2003-2023 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# Obtaining file system usage information. # Written by Jim Meyering. @@ -269,7 +269,7 @@ int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1]; # Check for SunOS statfs brokenness wrt partitions 2GB and larger. # If exists and struct statfs has a member named f_spare, -# enable the work-around code in fsusage.c. +# enable the workaround code in fsusage.c. AC_DEFUN([gl_STATFS_TRUNCATES], [ AC_CACHE_CHECK([for statfs that truncates block counts], diff --git a/gl/m4/ftell.m4 b/gl/m4/ftell.m4 index 79f1aaf..ab10736 100644 --- a/gl/m4/ftell.m4 +++ b/gl/m4/ftell.m4 @@ -1,5 +1,6 @@ -# ftell.m4 serial 3 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# ftell.m4 +# serial 3 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4 index 4901b16..0eb8fa0 100644 --- a/gl/m4/ftello.m4 +++ b/gl/m4/ftello.m4 @@ -1,5 +1,6 @@ -# ftello.m4 serial 14 -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# ftello.m4 +# serial 16 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -37,13 +38,24 @@ AC_DEFUN([gl_FUNC_FTELLO], if test $gl_cv_var_stdin_large_offset = no; then REPLACE_FTELLO=1 fi + AC_REQUIRE([AC_CANONICAL_HOST]) + if test $REPLACE_FTELLO = 0; then + dnl On native Windows, in some circumstances, ftell(), ftello(), + dnl fgetpos(), lseek(), _lseeki64() all succeed on devices of type + dnl FILE_TYPE_PIPE. However, to match POSIX behaviour, we want + dnl ftell(), ftello(), fgetpos(), lseek() to fail when the argument fd + dnl designates a pipe. See also + dnl https://github.com/python/cpython/issues/78961#issuecomment-1093800325 + case "$host_os" in + mingw* | windows*) REPLACE_FTELLO=1 ;; + esac + fi if test $REPLACE_FTELLO = 0; then dnl Detect bug on Solaris. dnl ftell and ftello produce incorrect results after putc that followed a dnl getc call that reached EOF on Solaris. This is because the _IOREAD dnl flag does not get cleared in this case, even though _IOWRT gets set, dnl and ftell and ftello look whether the _IOREAD flag is set. - AC_REQUIRE([AC_CANONICAL_HOST]) AC_CACHE_CHECK([whether ftello works], [gl_cv_func_ftello_works], [ @@ -51,12 +63,12 @@ AC_DEFUN([gl_FUNC_FTELLO], dnl be opened. changequote(,)dnl case "$host_os" in - # Guess no on Solaris. - solaris*) gl_cv_func_ftello_works="guessing no" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_ftello_works="guessing yes" ;; - # Guess yes otherwise. - *) gl_cv_func_ftello_works="guessing yes" ;; + # Guess no on Solaris. + solaris*) gl_cv_func_ftello_works="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_ftello_works="guessing yes" ;; + # Guess yes otherwise. + *) gl_cv_func_ftello_works="guessing yes" ;; esac changequote([,])dnl AC_RUN_IFELSE( diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4 index 15f09ff..8e20917 100644 --- a/gl/m4/getaddrinfo.m4 +++ b/gl/m4/getaddrinfo.m4 @@ -1,5 +1,6 @@ -# getaddrinfo.m4 serial 34 -dnl Copyright (C) 2004-2023 Free Software Foundation, Inc. +# getaddrinfo.m4 +# serial 35 +dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -41,7 +42,7 @@ AC_DEFUN([gl_GETADDRINFO], AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32], gl_cv_w32_getaddrinfo, [ gl_cv_w32_getaddrinfo=no - am_save_LIBS="$LIBS" + gl_saved_LIBS="$LIBS" LIBS="$LIBS -lws2_32" AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_WS2TCPIP_H @@ -49,7 +50,7 @@ AC_DEFUN([gl_GETADDRINFO], #endif #include ]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], [gl_cv_w32_getaddrinfo=yes]) - LIBS="$am_save_LIBS" + LIBS="$gl_saved_LIBS" ]) if test "$gl_cv_w32_getaddrinfo" = "yes"; then GETADDRINFO_LIB="-lws2_32" diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4 index 9aaed20..6113903 100644 --- a/gl/m4/getdelim.m4 +++ b/gl/m4/getdelim.m4 @@ -1,6 +1,7 @@ -# getdelim.m4 serial 16 +# getdelim.m4 +# serial 19 -dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. +dnl Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc. dnl dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -18,7 +19,7 @@ AC_DEFUN([gl_FUNC_GETDELIM], AC_CHECK_DECLS_ONCE([getdelim]) - AC_CHECK_FUNCS_ONCE([getdelim]) + gl_CHECK_FUNCS_ANDROID([getdelim], [[#include ]]) if test $ac_cv_func_getdelim = yes; then HAVE_GETDELIM=1 dnl Found it in some library. Verify that it works. @@ -82,8 +83,8 @@ AC_DEFUN([gl_FUNC_GETDELIM], ], [gl_cv_func_working_getdelim="guessing yes"], [case "$host_os" in - *-musl*) gl_cv_func_working_getdelim="guessing yes" ;; - *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;; + *-musl* | midipix*) gl_cv_func_working_getdelim="guessing yes" ;; + *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;; esac ]) ]) @@ -96,6 +97,9 @@ AC_DEFUN([gl_FUNC_GETDELIM], esac else HAVE_GETDELIM=0 + case "$gl_cv_onwards_func_getdelim" in + future*) REPLACE_GETDELIM=1 ;; + esac fi if test $ac_cv_have_decl_getdelim = no; then diff --git a/gl/m4/getdtablesize.m4 b/gl/m4/getdtablesize.m4 index 8bcda90..aaefe9b 100644 --- a/gl/m4/getdtablesize.m4 +++ b/gl/m4/getdtablesize.m4 @@ -1,5 +1,6 @@ -# getdtablesize.m4 serial 8 -dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. +# getdtablesize.m4 +# serial 8 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/gethostname.m4 b/gl/m4/gethostname.m4 index 63f5f63..2f743b7 100644 --- a/gl/m4/gethostname.m4 +++ b/gl/m4/gethostname.m4 @@ -1,5 +1,6 @@ -# gethostname.m4 serial 15 -dnl Copyright (C) 2002, 2008-2023 Free Software Foundation, Inc. +# gethostname.m4 +# serial 16 +dnl Copyright (C) 2002, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -20,7 +21,7 @@ AC_DEFUN([gl_FUNC_GETHOSTNAME], AC_CACHE_CHECK([for gethostname in winsock2.h and -lws2_32], [gl_cv_w32_gethostname], [gl_cv_w32_gethostname=no - gl_save_LIBS="$LIBS" + gl_saved_LIBS="$LIBS" LIBS="$LIBS -lws2_32" AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_WINSOCK2_H @@ -28,7 +29,7 @@ AC_DEFUN([gl_FUNC_GETHOSTNAME], #endif #include ]], [[gethostname(NULL, 0);]])], [gl_cv_w32_gethostname=yes]) - LIBS="$gl_save_LIBS" + LIBS="$gl_saved_LIBS" ]) if test "$gl_cv_w32_gethostname" = "yes"; then GETHOSTNAME_LIB="-lws2_32" diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4 index 03569f0..36513cd 100644 --- a/gl/m4/getline.m4 +++ b/gl/m4/getline.m4 @@ -1,6 +1,7 @@ -# getline.m4 serial 30 +# getline.m4 +# serial 33 -dnl Copyright (C) 1998-2003, 2005-2007, 2009-2023 Free Software Foundation, +dnl Copyright (C) 1998-2003, 2005-2007, 2009-2024 Free Software Foundation, dnl Inc. dnl dnl This file is free software; the Free Software Foundation @@ -23,12 +24,9 @@ AC_DEFUN([gl_FUNC_GETLINE], AC_CHECK_DECLS_ONCE([getline]) - gl_getline_needs_run_time_check=no - AC_CHECK_FUNC([getline], - [dnl Found it in some library. Verify that it works. - gl_getline_needs_run_time_check=yes], - [am_cv_func_working_getline=no]) - if test $gl_getline_needs_run_time_check = yes; then + gl_CHECK_FUNCS_ANDROID([getline], [[#include ]]) + if test $ac_cv_func_getline = yes; then + dnl Found it in some library. Verify that it works. AC_CACHE_CHECK([for working getline function], [am_cv_func_working_getline], [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data @@ -79,12 +77,17 @@ AC_DEFUN([gl_FUNC_GETLINE], ], [am_cv_func_working_getline="guessing yes"], [case "$host_os" in - *-musl*) am_cv_func_working_getline="guessing yes" ;; - *) am_cv_func_working_getline="$gl_cross_guess_normal" ;; + *-musl* | midipix*) am_cv_func_working_getline="guessing yes" ;; + *) am_cv_func_working_getline="$gl_cross_guess_normal" ;; esac ]) ]) ]) + else + am_cv_func_working_getline=no + case "$gl_cv_onwards_func_getline" in + future*) REPLACE_GETLINE=1 ;; + esac fi if test $ac_cv_have_decl_getline = no; then diff --git a/gl/m4/getloadavg.m4 b/gl/m4/getloadavg.m4 index 79e420b..0918bcd 100644 --- a/gl/m4/getloadavg.m4 +++ b/gl/m4/getloadavg.m4 @@ -1,13 +1,12 @@ -# Check for getloadavg. - -# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2023 Free Software -# Foundation, Inc. +# getloadavg.m4 +# serial 13 +dnl Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2024 Free Software +dnl Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -#serial 10 +# Check for getloadavg. # Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent. # New applications should use gl_GETLOADAVG instead. @@ -20,13 +19,18 @@ AC_DEFUN([gl_GETLOADAVG], # Persuade glibc to declare getloadavg(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) -gl_save_LIBS=$LIBS +gl_saved_LIBS=$LIBS # getloadavg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0, # NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7. HAVE_GETLOADAVG=1 -AC_CHECK_FUNC([getloadavg], [], - [gl_func_getloadavg_done=no +gl_CHECK_FUNCS_ANDROID([getloadavg], [[#include ]]) +if test $ac_cv_func_getloadavg != yes; then + case "$gl_cv_onwards_func_getloadavg" in + future*) REPLACE_GETLOADAVG=1 ;; + esac + + gl_func_getloadavg_done=no # Some systems with -lutil have (and need) -lkvm as well, some do not. # On Solaris, -lkvm requires nlist from -lelf, so check that first @@ -73,14 +77,15 @@ AC_CHECK_FUNC([getloadavg], [], AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with .]) AC_CHECK_LIB([dgc], [dg_sys_info])]) fi - fi]) + fi +fi -if test "x$gl_save_LIBS" = x; then +if test "x$gl_saved_LIBS" = x; then GETLOADAVG_LIBS=$LIBS else - GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$gl_save_LIBS!!"` + GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$gl_saved_LIBS!!"` fi -LIBS=$gl_save_LIBS +LIBS=$gl_saved_LIBS AC_SUBST([GETLOADAVG_LIBS])dnl diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4 index 7981a09..297722e 100644 --- a/gl/m4/getopt.m4 +++ b/gl/m4/getopt.m4 @@ -1,5 +1,6 @@ -# getopt.m4 serial 48 -dnl Copyright (C) 2002-2006, 2008-2023 Free Software Foundation, Inc. +# getopt.m4 +# serial 49 +dnl Copyright (C) 2002-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -197,8 +198,8 @@ main () fi else case "$host_os" in - darwin* | aix* | mingw*) gl_cv_func_getopt_posix="guessing no";; - *) gl_cv_func_getopt_posix="guessing yes";; + darwin* | aix* | mingw* | windows*) gl_cv_func_getopt_posix="guessing no";; + *) gl_cv_func_getopt_posix="guessing yes";; esac fi ]) diff --git a/gl/m4/getprogname.m4 b/gl/m4/getprogname.m4 index b67c527..b24f448 100644 --- a/gl/m4/getprogname.m4 +++ b/gl/m4/getprogname.m4 @@ -1,16 +1,33 @@ -# getprogname.m4 - check for getprogname or replacements for it +# getprogname.m4 +# serial 8 +dnl Copyright (C) 2016-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -# Copyright (C) 2016-2023 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 +# Check for getprogname or replacements for it AC_DEFUN([gl_FUNC_GETPROGNAME], [ - AC_CHECK_FUNCS_ONCE([getprogname getexecname]) + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + gl_CHECK_FUNCS_ANDROID([getprogname], [[#include ]]) + if test $ac_cv_func_getprogname = no; then + HAVE_GETPROGNAME=0 + case "$gl_cv_onwards_func_getprogname" in + future*) REPLACE_GETPROGNAME=1 ;; + esac + fi + AC_CHECK_DECLS([program_invocation_name], + [], + [HAVE_DECL_PROGRAM_INVOCATION_NAME=0], + [[#include ]]) +]) + +AC_DEFUN([gl_PREREQ_GETPROGNAME], +[ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([getexecname]) ac_found=0 AC_CHECK_DECLS([program_invocation_name], [ac_found=1], [], [#include ]) diff --git a/gl/m4/gl-openssl.m4 b/gl/m4/gl-openssl.m4 index 7eab4e1..c5e1f7b 100644 --- a/gl/m4/gl-openssl.m4 +++ b/gl/m4/gl-openssl.m4 @@ -1,5 +1,6 @@ -# gl-openssl.m4 serial 6 -dnl Copyright (C) 2013-2023 Free Software Foundation, Inc. +# gl-openssl.m4 +# serial 7 +dnl Copyright (C) 2013-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -39,6 +40,9 @@ AC_DEFUN([gl_CRYPTO_CHECK], AC_SUBST([LIB_CRYPTO]) if test "x$with_openssl" != xno; then if test "x$with_openssl" = xauto-gpl-compat; then + dnl OpenSSL versions < 3 are under the OpenSSL license, which is not + dnl GPL compatible. + dnl See . AC_CACHE_CHECK([whether openssl is GPL compatible], [gl_cv_openssl_gpl_compat], [AC_COMPILE_IFELSE( diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index 267f069..fcf8422 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2023 Free Software Foundation, Inc. +# Copyright (C) 2002-2024 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index facc340..cb73044 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 @@ -1,5 +1,6 @@ -# gnulib-common.m4 serial 75a -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# gnulib-common.m4 +# serial 93 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -15,6 +16,10 @@ AC_DEFUN([gl_COMMON], [ AC_REQUIRE([gl_ZZGNULIB]) ]) AC_DEFUN([gl_COMMON_BODY], [ + AH_VERBATIM([0witness], +[/* Witness that has been included. */ +#define _GL_CONFIG_H_INCLUDED 1 +]) AH_VERBATIM([_GL_GNUC_PREREQ], [/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ #if defined __GNUC__ && defined __GNUC_MINOR__ @@ -72,50 +77,74 @@ AC_DEFUN([gl_COMMON_BODY], [ #endif]) AH_VERBATIM([attribute], [/* Attributes. */ -#if (defined __has_attribute \ - && (!defined __clang_minor__ \ - || (defined __apple_build_version__ \ - ? 6000000 <= __apple_build_version__ \ - : 3 < __clang_major__ + (5 <= __clang_minor__)))) -# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) -#else -# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr -# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) -# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) -# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) -# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3) -# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95) -# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1) -# define _GL_ATTR_diagnose_if 0 -# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3) -# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1) -# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) -# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7) -# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6) -# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) -# ifdef _ICC -# define _GL_ATTR_may_alias 0 +/* Define _GL_HAS_ATTRIBUTE only once, because on FreeBSD, with gcc < 5, if + gets included once again after , __has_attribute(x) + expands to 0 always, and redefining _GL_HAS_ATTRIBUTE would turn off all + attributes. */ +#ifndef _GL_HAS_ATTRIBUTE +# if (defined __has_attribute \ + && (!defined __clang_minor__ \ + || (defined __apple_build_version__ \ + ? 7000000 <= __apple_build_version__ \ + : 5 <= __clang_major__))) +# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) # else -# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) +# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr +# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) +# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95) +# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1) +# define _GL_ATTR_diagnose_if 0 +# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1) +# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) +# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6) +# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) +# ifdef _ICC +# define _GL_ATTR_may_alias 0 +# else +# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) +# endif +# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) +# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) +# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) +# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) +# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) +# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) +# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) +# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) # endif -# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) -# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) -# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) -# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) -# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) -# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) -# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) -# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) -# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) -# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) #endif -/* Disable GCC -Wpedantic if using __has_c_attribute and this is not C23+. */ -#if (defined __has_c_attribute && _GL_GNUC_PREREQ (4, 6) \ - && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710) -# pragma GCC diagnostic ignored "-Wpedantic" +/* Use __has_c_attribute if available. However, do not use with + pre-C23 GCC, which can issue false positives if -Wpedantic. */ +#if (defined __has_c_attribute \ + && ! (_GL_GNUC_PREREQ (4, 6) \ + && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710)) +# define _GL_HAVE___HAS_C_ATTRIBUTE 1 +#else +# define _GL_HAVE___HAS_C_ATTRIBUTE 0 #endif +/* Define if, in a function declaration, the attributes in bracket syntax + [[...]] must come before the attributes in __attribute__((...)) syntax. + If this is defined, it is best to avoid the bracket syntax, so that the + various _GL_ATTRIBUTE_* can be cumulated on the same declaration in any + order. */ +#ifdef __cplusplus +# if defined __clang__ +# define _GL_BRACKET_BEFORE_ATTRIBUTE 1 +# endif +#else +# if defined __GNUC__ && !defined __clang__ +# define _GL_BRACKET_BEFORE_ATTRIBUTE 1 +# endif +#endif ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead. [ /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function @@ -223,9 +252,11 @@ AC_DEFUN([gl_COMMON_BODY], [ - typedef, in C++ also: namespace, class, template specialization. */ #ifndef _GL_ATTRIBUTE_DEPRECATED -# ifdef __has_c_attribute -# if __has_c_attribute (__deprecated__) -# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if _GL_HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute (__deprecated__) +# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] +# endif # endif # endif # if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated) @@ -271,7 +302,7 @@ AC_DEFUN([gl_COMMON_BODY], [ /* Applies to: Empty statement (;), inside a 'switch' statement. */ /* Always expands to something. */ #ifndef _GL_ATTRIBUTE_FALLTHROUGH -# ifdef __has_c_attribute +# if _GL_HAVE___HAS_C_ATTRIBUTE # if __has_c_attribute (__fallthrough__) # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] # endif @@ -351,11 +382,19 @@ AC_DEFUN([gl_COMMON_BODY], [ in C++ also: class. */ /* In C++ and C23, this is spelled [[__maybe_unused__]]. GCC's syntax is __attribute__ ((__unused__)). - clang supports both syntaxes. */ + clang supports both syntaxes. Except that with clang ≥ 6, < 10, in C++ mode, + __has_c_attribute (__maybe_unused__) yields true but the use of + [[__maybe_unused__]] nevertheless produces a warning. */ #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED -# ifdef __has_c_attribute -# if __has_c_attribute (__maybe_unused__) -# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if defined __clang__ && defined __cplusplus +# if !defined __apple_build_version__ && __clang_major__ >= 10 +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif +# elif _GL_HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute (__maybe_unused__) +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif # endif # endif # ifndef _GL_ATTRIBUTE_MAYBE_UNUSED @@ -373,9 +412,20 @@ AC_DEFUN([gl_COMMON_BODY], [ the return value, unless the caller uses something like ignore_value. */ /* Applies to: function, enumeration, class. */ #ifndef _GL_ATTRIBUTE_NODISCARD -# ifdef __has_c_attribute -# if __has_c_attribute (__nodiscard__) -# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if defined __clang__ && defined __cplusplus + /* With clang up to 15.0.6 (at least), in C++ mode, [[__nodiscard__]] produces + a warning. + The 1000 below means a yet unknown threshold. When clang++ version X + starts supporting [[__nodiscard__]] without warning about it, you can + replace the 1000 with X. */ +# if __clang_major__ >= 1000 +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# endif +# elif _GL_HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute (__nodiscard__) +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# endif # endif # endif # if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result) @@ -427,11 +477,25 @@ AC_DEFUN([gl_COMMON_BODY], [ /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. */ /* Applies to: functions. */ +/* After a function's parameter list, this attribute must come first, before + other attributes. */ #ifndef _GL_ATTRIBUTE_NOTHROW -# if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus -# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# if defined __cplusplus +# if _GL_GNUC_PREREQ (2, 8) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif # else -# define _GL_ATTRIBUTE_NOTHROW +# if _GL_HAS_ATTRIBUTE (nothrow) +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif # endif #endif @@ -441,8 +505,10 @@ AC_DEFUN([gl_COMMON_BODY], [ minimizing the memory required. */ /* Applies to: struct members, struct, union, in C++ also: class. */ +/* Oracle Studio 12.6 miscompiles code with __attribute__ ((__packed__)) despite + __has_attribute OK. */ #ifndef _GL_ATTRIBUTE_PACKED -# if _GL_HAS_ATTRIBUTE (packed) +# if _GL_HAS_ATTRIBUTE (packed) && !defined __SUNPRO_C # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) # else # define _GL_ATTRIBUTE_PACKED @@ -513,6 +579,18 @@ AC_DEFUN([gl_COMMON_BODY], [ # endif #endif ]) + AH_VERBATIM([c_linkage], +[/* In C++, there is the concept of "language linkage", that encompasses + name mangling and function calling conventions. + The following macros start and end a block of "C" linkage. */ +#ifdef __cplusplus +# define _GL_BEGIN_C_LINKAGE extern "C" { +# define _GL_END_C_LINKAGE } +#else +# define _GL_BEGIN_C_LINKAGE +# define _GL_END_C_LINKAGE +#endif +]) AH_VERBATIM([async_safe], [/* The _GL_ASYNC_SAFE marker should be attached to functions that are signal handlers (for signals other than SIGABRT, SIGPIPE) or can be @@ -568,7 +646,7 @@ AC_DEFUN([gl_COMMON_BODY], [ dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad), dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad). AC_ARG_ENABLE([cross-guesses], - [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}], + [AS_HELP_STRING([[--enable-cross-guesses={conservative|risky}]], [specify policy for cross-compilation guesses])], [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses]) @@ -1005,6 +1083,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], dnl -Wno-pedantic >= 4.8 >= 3.9 dnl -Wno-sign-compare >= 3 >= 3.9 dnl -Wno-sign-conversion >= 4.3 >= 3.9 + dnl -Wno-tautological-out-of-range-compare - >= 3.9 dnl -Wno-type-limits >= 4.3 >= 3.9 dnl -Wno-undef >= 3 >= 3.9 dnl -Wno-unsuffixed-float-constants >= 4.5 @@ -1030,6 +1109,9 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-pedantic #endif + #if 3 < __clang_major__ + (9 <= __clang_minor__) + -Wno-tautological-constant-out-of-range-compare + #endif #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) -Wno-sign-conversion -Wno-type-limits @@ -1080,6 +1162,238 @@ AC_DEFUN([gl_CONDITIONAL_HEADER], m4_popdef([gl_header_name]) ]) +dnl Preparations for gl_CHECK_FUNCS_MACOS. +AC_DEFUN([gl_PREPARE_CHECK_FUNCS_MACOS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_COMPILER_CLANG]) + AC_CACHE_CHECK([for compiler option needed when checking for future declarations], + [gl_cv_compiler_check_future_option], + [case "$host_os" in + dnl This is only needed on macOS. + darwin*) + if test $gl_cv_compiler_clang = yes; then + dnl Test whether the compiler supports the option + dnl '-Werror=unguarded-availability-new'. + saved_ac_compile="$ac_compile" + ac_compile="$ac_compile -Werror=unguarded-availability-new" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])], + [gl_cv_compiler_check_future_option='-Werror=unguarded-availability-new'], + [gl_cv_compiler_check_future_option=none]) + ac_compile="$saved_ac_compile" + else + gl_cv_compiler_check_future_option=none + fi + ;; + *) gl_cv_compiler_check_future_option=none ;; + esac + ]) +]) + +dnl Pieces of the expansion of +dnl gl_CHECK_FUNCS_ANDROID +dnl gl_CHECK_FUNCS_MACOS +dnl gl_CHECK_FUNCS_ANDROID_MACOS + +AC_DEFUN([gl_CHECK_FUNCS_DEFAULT_CASE], +[ + *) + AC_CHECK_FUNC([$1]) + [gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1] + ;; +]) + +AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_ANDROID], +[ + linux*-android*) + AC_CHECK_DECL([$1], , , [$2]) + if test $[ac_cv_have_decl_][$1] = yes; then + AC_CHECK_FUNC([[$1]]) + if test $[ac_cv_func_][$1] = yes; then + [gl_cv_onwards_func_][$1]=yes + else + dnl The function is declared but does not exist. This should not + dnl happen normally. But anyway, we know that a future version + dnl of Android will have the function. + [gl_cv_onwards_func_][$1]='future OS version' + fi + else + [gl_cv_onwards_func_][$1]='future OS version' + fi + ;; +]) + +AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_MACOS], +[ + darwin*) + if test "x$gl_cv_compiler_check_future_option" != "xnone"; then + dnl Use a compile test, not a link test. + saved_ac_compile="$ac_compile" + ac_compile="$ac_compile $gl_cv_compiler_check_future_option" + saved_ac_compile_for_check_decl="$ac_compile_for_check_decl" + ac_compile_for_check_decl="$ac_compile_for_check_decl $gl_cv_compiler_check_future_option" + unset [ac_cv_have_decl_][$1] + AC_CHECK_DECL([$1], , , [$2]) + ac_compile="$saved_ac_compile" + ac_compile_for_check_decl="$saved_ac_compile_for_check_decl" + [ac_cv_func_][$1]="$[ac_cv_have_decl_][$1]" + if test $[ac_cv_func_][$1] = yes; then + [gl_cv_onwards_func_][$1]=yes + else + unset [ac_cv_have_decl_][$1] + AC_CHECK_DECL([$1], , , [$2]) + if test $[ac_cv_have_decl_][$1] = yes; then + [gl_cv_onwards_func_][$1]='future OS version' + else + [gl_cv_onwards_func_][$1]=no + fi + fi + else + AC_CHECK_FUNC([$1]) + [gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1] + fi + ;; +]) + +AC_DEFUN([gl_CHECK_FUNCS_SET_RESULTS], +[ + case "$[gl_cv_onwards_func_][$1]" in + future*) [ac_cv_func_][$1]=no ;; + *) [ac_cv_func_][$1]=$[gl_cv_onwards_func_][$1] ;; + esac + if test $[ac_cv_func_][$1] = yes; then + AC_DEFINE([HAVE_]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ]), + [1], [Define to 1 if you have the `$1' function.]) + fi +]) + +dnl gl_CHECK_FUNCS_ANDROID([func], [[#include ]]) +dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem +dnl on Android. +dnl +dnl When code is compiled on Android, it is in the context of a certain +dnl "Android API level", which indicates the minimum version of Android on +dnl which the app can be installed. In other words, you don't compile for a +dnl specific version of Android. You compile for all versions of Android, +dnl onwards from the given API level. +dnl Thus, the question "does the OS have the function func" has three possible +dnl answers: +dnl - yes, in all versions starting from the given API level, +dnl - no, in no version, +dnl - not in the given API level, but in a later version of Android. +dnl +dnl In detail, this works as follows: +dnl If func was added to Android API level, say, 28, then the libc.so has the +dnl symbol func always, whereas the header file declares func +dnl conditionally: +dnl #if __ANDROID_API__ >= 28 +dnl ... func (...) __INTRODUCED_IN(28); +dnl #endif +dnl Thus, when compiling with "clang -target armv7a-unknown-linux-android28", +dnl the function func is declared and exists in libc. +dnl Whereas when compiling with "clang -target armv7a-unknown-linux-android27", +dnl the function func is not declared but exists in libc. +dnl +dnl This macro sets two variables: +dnl - gl_cv_onwards_func_ to yes / no / "future OS version" +dnl - ac_cv_func_ to yes / no / no +dnl The first variable allows to distinguish all three cases. +dnl The second variable is set, so that an invocation +dnl gl_CHECK_FUNCS_ANDROID([func], [[#include ]]) +dnl can be used as a drop-in replacement for +dnl AC_CHECK_FUNCS([func]). +AC_DEFUN([gl_CHECK_FUNCS_ANDROID], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([for [$1]], + [[gl_cv_onwards_func_][$1]], + [gl_SILENT([ + case "$host_os" in + gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2]) + gl_CHECK_FUNCS_DEFAULT_CASE([$1]) + esac + ]) + ]) + gl_CHECK_FUNCS_SET_RESULTS([$1]) +]) + +dnl gl_CHECK_FUNCS_MACOS([func], [[#include ]]) +dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem +dnl on macOS. +dnl +dnl When code is compiled on macOS, it is in the context of a certain minimum +dnl macOS version, that can be set through the option '-mmacosx-version-min='. +dnl In other words, you don't compile for a specific version of macOS. You +dnl compile for all versions of macOS, onwards from the given version. +dnl Thus, the question "does the OS have the function func" has three possible +dnl answers: +dnl - yes, in all versions starting from the given version, +dnl - no, in no version, +dnl - not in the given version, but in a later version of macOS. +dnl +dnl In detail, this works as follows: +dnl If func was added to, say, macOS version 13, then the libc has the +dnl symbol func always, whereas the header file declares func +dnl conditionally with a special availability attribute: +dnl ... func (...) __attribute__((availability(macos,introduced=13.0))); +dnl Thus, when compiling with "clang mmacosx-version-min=13", there is no +dnl warning about the use of func, and the resulting binary +dnl - runs fine on macOS 13, +dnl - aborts with a dyld "Symbol not found" message on macOS 12. +dnl Whereas, when compiling with "clang mmacosx-version-min=12", there is a +dnl warning: 'func' is only available on macOS 13.0 or newer +dnl [-Wunguarded-availability-new], +dnl and the resulting binary +dnl - runs fine on macOS 13, +dnl - crashes with a SIGSEGV (signal 11) on macOS 12. +dnl +dnl This macro sets two variables: +dnl - gl_cv_onwards_func_ to yes / no / "future OS version" +dnl - ac_cv_func_ to yes / no / no +dnl The first variable allows to distinguish all three cases. +dnl The second variable is set, so that an invocation +dnl gl_CHECK_FUNCS_MACOS([func], [[#include ]]) +dnl can be used as a drop-in replacement for +dnl AC_CHECK_FUNCS([func]). +AC_DEFUN([gl_CHECK_FUNCS_MACOS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS]) + AC_CACHE_CHECK([for [$1]], + [[gl_cv_onwards_func_][$1]], + [gl_SILENT([ + case "$host_os" in + gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2]) + gl_CHECK_FUNCS_DEFAULT_CASE([$1]) + esac + ]) + ]) + gl_CHECK_FUNCS_SET_RESULTS([$1]) +]) + +dnl gl_CHECK_FUNCS_ANDROID_MACOS([func], [[#include ]]) +dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem +dnl on Android and on macOS. +dnl It is the combination of gl_CHECK_FUNCS_ANDROID and gl_CHECK_FUNCS_MACOS. +AC_DEFUN([gl_CHECK_FUNCS_ANDROID_MACOS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS]) + AC_CACHE_CHECK([for [$1]], + [[gl_cv_onwards_func_][$1]], + [gl_SILENT([ + case "$host_os" in + gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2]) + gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2]) + gl_CHECK_FUNCS_DEFAULT_CASE([$1]) + esac + ]) + ]) + gl_CHECK_FUNCS_SET_RESULTS([$1]) +]) + dnl Expands to some code for use in .c programs that, on native Windows, defines dnl the Microsoft deprecated alias function names to the underscore-prefixed dnl actual function names. With this macro, these function names are available diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 4764622..83a0f72 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -1,5 +1,5 @@ # DO NOT EDIT! GENERATED AUTOMATICALLY! -# Copyright (C) 2002-2023 Free Software Foundation, Inc. +# Copyright (C) 2002-2024 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,6 +43,7 @@ AC_DEFUN([gl_EARLY], AC_REQUIRE([gl_PROG_AR_RANLIB]) # Code from module absolute-header: + # Code from module alignasof: # Code from module alloca-opt: # Code from module arpa_inet: # Code from module assert-h: @@ -67,6 +68,7 @@ AC_DEFUN([gl_EARLY], # Code from module environ: # Code from module errno: # Code from module error: + # Code from module error-h: # Code from module exitfail: # Code from module extensions: # Code from module extern-inline: @@ -112,6 +114,11 @@ AC_DEFUN([gl_EARLY], # Code from module inet_ntop: # Code from module intprops: # Code from module inttypes-incomplete: + # Code from module iswblank: + # Code from module iswctype: + # Code from module iswdigit: + # Code from module iswpunct: + # Code from module iswxdigit: # Code from module langinfo: # Code from module largefile: AC_REQUIRE([AC_SYS_LARGEFILE]) @@ -128,6 +135,7 @@ AC_DEFUN([gl_EARLY], # Code from module math: # Code from module mbrtowc: # Code from module mbsinit: + # Code from module mbszero: # Code from module mbtowc: # Code from module memchr: # Code from module minmax: @@ -150,6 +158,7 @@ AC_DEFUN([gl_EARLY], # Code from module servent: # Code from module setenv: # Code from module setlocale-null: + # Code from module setlocale-null-unlocked: # Code from module size_max: # Code from module snippet/_Noreturn: # Code from module snippet/arg-nonnull: @@ -163,12 +172,12 @@ AC_DEFUN([gl_EARLY], # Code from module stat: # Code from module stat-time: # Code from module std-gnu11: - # Code from module stdalign: # Code from module stdbool: # Code from module stdckdint: # Code from module stddef: # Code from module stdint: # Code from module stdio: + gl_STDIO_H_EARLY # Code from module stdlib: # Code from module strcase: # Code from module strcasestr: @@ -186,7 +195,7 @@ AC_DEFUN([gl_EARLY], # Code from module sys_uio: # Code from module threadlib: gl_THREADLIB_EARLY - # Code from module time: + # Code from module time-h: # Code from module time_r: # Code from module timegm: # Code from module unistd: @@ -199,6 +208,7 @@ AC_DEFUN([gl_EARLY], # Code from module vsnprintf: # Code from module wchar: # Code from module wcrtomb: + # Code from module wctype: # Code from module wctype-h: # Code from module windows-mutex: # Code from module windows-once: @@ -229,6 +239,7 @@ AC_DEFUN([gl_INIT], gl_COMMON gl_source_base='gl' gl_source_base_prefix= + gl_ALIGNASOF gl_FUNC_ALLOCA gl_CONDITIONAL_HEADER([alloca.h]) AC_PROG_MKDIR_P @@ -280,14 +291,17 @@ AC_DEFUN([gl_INIT], gl_HEADER_ERRNO_H gl_CONDITIONAL_HEADER([errno.h]) AC_PROG_MKDIR_P + AC_REQUIRE([gl_ERROR_H]) gl_ERROR - gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test "$ac_cv_lib_error_at_line" = no]) + gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test $COMPILE_ERROR_C = 1]) AM_COND_IF([GL_COND_OBJ_ERROR], [ gl_PREREQ_ERROR ]) m4_ifdef([AM_XGETTEXT_OPTION], [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) + gl_ERROR_H + AC_PROG_MKDIR_P AC_REQUIRE([gl_EXTERN_INLINE]) gl_FUNC_FCNTL gl_CONDITIONAL([GL_COND_OBJ_FCNTL], @@ -350,7 +364,7 @@ AC_DEFUN([gl_INIT], gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1]) AM_COND_IF([GL_COND_OBJ_FSTAT], [ case "$host_os" in - mingw*) + mingw* | windows*) AC_LIBOBJ([stat-w32]) ;; esac @@ -406,7 +420,8 @@ AC_DEFUN([gl_INIT], gl_STDIO_MODULE_INDICATOR([getline]) AC_REQUIRE([AC_CANONICAL_HOST]) gl_GETLOADAVG - gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], [test $HAVE_GETLOADAVG = 0]) + gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], + [test $HAVE_GETLOADAVG = 0 || test $REPLACE_GETLOADAVG = 1]) AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [ gl_PREREQ_GETLOADAVG ]) @@ -427,11 +442,20 @@ AC_DEFUN([gl_INIT], ]) gl_UNISTD_MODULE_INDICATOR([getopt-posix]) gl_FUNC_GETPROGNAME + gl_CONDITIONAL([GL_COND_OBJ_GETPROGNAME], + [test $HAVE_GETPROGNAME = 0 || test $REPLACE_GETPROGNAME = 1]) + AM_COND_IF([GL_COND_OBJ_GETPROGNAME], [ + gl_PREREQ_GETPROGNAME + ]) + gl_STDLIB_MODULE_INDICATOR([getprogname]) AC_SUBST([LIBINTL]) AC_SUBST([LTLIBINTL]) AC_PROG_MKDIR_P AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) - LIB_HARD_LOCALE="$LIB_SETLOCALE_NULL" + HARD_LOCALE_LIB="$SETLOCALE_NULL_LIB" + AC_SUBST([HARD_LOCALE_LIB]) + dnl For backward compatibility. + LIB_HARD_LOCALE="$HARD_LOCALE_LIB" AC_SUBST([LIB_HARD_LOCALE]) gl_HOSTENT gl_IDPRIV @@ -445,6 +469,26 @@ AC_DEFUN([gl_INIT], gl_INTTYPES_INCOMPLETE gl_INTTYPES_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P + gl_FUNC_ISWBLANK + gl_CONDITIONAL([GL_COND_OBJ_ISWBLANK], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && { test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; }]) + gl_WCTYPE_MODULE_INDICATOR([iswblank]) + gl_FUNC_ISWCTYPE + gl_CONDITIONAL([GL_COND_OBJ_ISWCTYPE], + [test $HAVE_WCTYPE_T = 0 || test $GNULIBHEADERS_OVERRIDE_WINT_T = 1 || test $REPLACE_WCTYPE = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswctype]) + gl_FUNC_ISWDIGIT + gl_CONDITIONAL([GL_COND_OBJ_ISWDIGIT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWDIGIT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswdigit]) + gl_FUNC_ISWPUNCT + gl_CONDITIONAL([GL_COND_OBJ_ISWPUNCT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWPUNCT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswpunct]) + gl_FUNC_ISWXDIGIT + gl_CONDITIONAL([GL_COND_OBJ_ISWXDIGIT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWXDIGIT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswxdigit]) gl_LANGINFO_H gl_LANGINFO_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P @@ -504,6 +548,10 @@ AC_DEFUN([gl_INIT], gl_PREREQ_MBSINIT ]) gl_WCHAR_MODULE_INDICATOR([mbsinit]) + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + gl_MBSTATE_T_BROKEN + gl_MUSL_LIBC + gl_WCHAR_MODULE_INDICATOR([mbszero]) gl_FUNC_MBTOWC gl_CONDITIONAL([GL_COND_OBJ_MBTOWC], [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]) @@ -611,7 +659,7 @@ AC_DEFUN([gl_INIT], gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1]) AM_COND_IF([GL_COND_OBJ_STAT], [ case "$host_os" in - mingw*) + mingw* | windows*) AC_LIBOBJ([stat-w32]) ;; esac @@ -620,9 +668,6 @@ AC_DEFUN([gl_INIT], gl_SYS_STAT_MODULE_INDICATOR([stat]) gl_STAT_TIME gl_STAT_BIRTHTIME - gl_STDALIGN_H - gl_CONDITIONAL_HEADER([stdalign.h]) - AC_PROG_MKDIR_P gl_C_BOOL AC_CHECK_HEADERS_ONCE([stdckdint.h]) if test $ac_cv_header_stdckdint_h = yes; then @@ -781,21 +826,24 @@ AC_DEFUN([gl_INIT], gl_PREREQ_WCRTOMB ]) gl_WCHAR_MODULE_INDICATOR([wcrtomb]) + gl_FUNC_WCTYPE + gl_CONDITIONAL([GL_COND_OBJ_WCTYPE], [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1]) + gl_WCTYPE_MODULE_INDICATOR([wctype]) gl_WCTYPE_H gl_WCTYPE_H_REQUIRE_DEFAULTS AC_PROG_MKDIR_P AC_REQUIRE([AC_CANONICAL_HOST]) gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_MUTEX], - [case "$host_os" in mingw*) true;; *) false;; esac]) + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) AC_REQUIRE([AC_CANONICAL_HOST]) gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_ONCE], - [case "$host_os" in mingw*) true;; *) false;; esac]) + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) AC_REQUIRE([AC_CANONICAL_HOST]) gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RECMUTEX], - [case "$host_os" in mingw*) true;; *) false;; esac]) + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) AC_REQUIRE([AC_CANONICAL_HOST]) gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RWLOCK], - [case "$host_os" in mingw*) true;; *) false;; esac]) + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) gl_XALLOC gl_MODULE_INDICATOR([xalloc]) gl_MODULE_INDICATOR([xalloc-die]) @@ -1002,7 +1050,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/dynarray.h lib/errno.in.h lib/error.c - lib/error.h + lib/error.in.h lib/exitfail.c lib/exitfail.h lib/fcntl.c @@ -1062,6 +1110,12 @@ AC_DEFUN([gl_FILE_LIST], [ lib/intprops-internal.h lib/intprops.h lib/inttypes.in.h + lib/iswblank.c + lib/iswctype-impl.h + lib/iswctype.c + lib/iswdigit.c + lib/iswpunct.c + lib/iswxdigit.c lib/itold.c lib/langinfo.in.h lib/lc-charset-dispatch.c @@ -1089,6 +1143,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/mbrtowc-impl.h lib/mbrtowc.c lib/mbsinit.c + lib/mbszero.c lib/mbtowc-impl.h lib/mbtowc-lock.c lib/mbtowc-lock.h @@ -1124,6 +1179,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/regexec.c lib/setenv.c lib/setlocale-lock.c + lib/setlocale_null-unlocked.c lib/setlocale_null.c lib/setlocale_null.h lib/sha256-stream.c @@ -1138,7 +1194,6 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stat-w32.c lib/stat-w32.h lib/stat.c - lib/stdalign.in.h lib/stdckdint.in.h lib/stddef.in.h lib/stdint.in.h @@ -1183,6 +1238,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/wchar.in.h lib/wcrtomb.c lib/wctype-h.c + lib/wctype-impl.h + lib/wctype.c lib/wctype.in.h lib/windows-initguard.h lib/windows-mutex.c @@ -1220,9 +1277,11 @@ AC_DEFUN([gl_FILE_LIST], [ m4/environ.m4 m4/errno_h.m4 m4/error.m4 + m4/error_h.m4 m4/exponentd.m4 m4/extensions.m4 m4/extern-inline.m4 + m4/fclose.m4 m4/fcntl-o.m4 m4/fcntl.m4 m4/fcntl_h.m4 @@ -1257,6 +1316,11 @@ AC_DEFUN([gl_FILE_LIST], [ m4/intmax_t.m4 m4/inttypes.m4 m4/inttypes_h.m4 + m4/iswblank.m4 + m4/iswctype.m4 + m4/iswdigit.m4 + m4/iswpunct.m4 + m4/iswxdigit.m4 m4/langinfo_h.m4 m4/largefile.m4 m4/limits-h.m4 @@ -1284,6 +1348,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/msvc-inval.m4 m4/msvc-nothrow.m4 m4/multiarch.m4 + m4/musl.m4 m4/netdb_h.m4 m4/netinet_in_h.m4 m4/nl_langinfo.m4 @@ -1346,6 +1411,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/wchar_h.m4 m4/wchar_t.m4 m4/wcrtomb.m4 + m4/wctype.m4 m4/wctype_h.m4 m4/wint_t.m4 m4/xalloc.m4 diff --git a/gl/m4/gnulib-tool.m4 b/gl/m4/gnulib-tool.m4 index a9dd569..ef45f51 100644 --- a/gl/m4/gnulib-tool.m4 +++ b/gl/m4/gnulib-tool.m4 @@ -1,5 +1,6 @@ -# gnulib-tool.m4 serial 4 -dnl Copyright (C) 2004-2005, 2009-2023 Free Software Foundation, Inc. +# gnulib-tool.m4 +# serial 4 +dnl Copyright (C) 2004-2005, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/hostent.m4 b/gl/m4/hostent.m4 index 3b2cc2b..36dc636 100644 --- a/gl/m4/hostent.m4 +++ b/gl/m4/hostent.m4 @@ -1,5 +1,6 @@ -# hostent.m4 serial 4 -dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. +# hostent.m4 +# serial 5 +dnl Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -26,7 +27,7 @@ AC_DEFUN([gl_HOSTENT], AC_CACHE_CHECK([for gethostbyname in winsock2.h and -lws2_32], [gl_cv_w32_gethostbyname], [gl_cv_w32_gethostbyname=no - gl_save_LIBS="$LIBS" + gl_saved_LIBS="$LIBS" LIBS="$LIBS -lws2_32" AC_LINK_IFELSE( [AC_LANG_PROGRAM( @@ -38,7 +39,7 @@ AC_DEFUN([gl_HOSTENT], ]], [[gethostbyname(NULL);]])], [gl_cv_w32_gethostbyname=yes]) - LIBS="$gl_save_LIBS" + LIBS="$gl_saved_LIBS" ]) if test "$gl_cv_w32_gethostbyname" = "yes"; then HOSTENT_LIB="-lws2_32" diff --git a/gl/m4/idpriv.m4 b/gl/m4/idpriv.m4 index fc3dd17..5369352 100644 --- a/gl/m4/idpriv.m4 +++ b/gl/m4/idpriv.m4 @@ -1,5 +1,6 @@ -# idpriv.m4 serial 1 -dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. +# idpriv.m4 +# serial 1 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4 index 9f19215..03e8525 100644 --- a/gl/m4/include_next.m4 +++ b/gl/m4/include_next.m4 @@ -1,5 +1,6 @@ -# include_next.m4 serial 26 -dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. +# include_next.m4 +# serial 27 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -74,17 +75,17 @@ EOF #endif #define DEFINED_IN_CONFTESTD2 EOF - gl_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" + gl_saved_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$gl_saved_CPPFLAGS -Iconftestd1b -Iconftestd2" dnl We intentionally avoid using AC_LANG_SOURCE here. AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include ]], [gl_cv_have_include_next=yes], - [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" + [CPPFLAGS="$gl_saved_CPPFLAGS -Iconftestd1a -Iconftestd2" AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include ]], [gl_cv_have_include_next=buggy], [gl_cv_have_include_next=no]) ]) - CPPFLAGS="$gl_save_CPPFLAGS" + CPPFLAGS="$gl_saved_CPPFLAGS" rm -rf conftestd1a conftestd1b conftestd2 ]) PRAGMA_SYSTEM_HEADER= diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4 index 48822d6..168e17e 100644 --- a/gl/m4/inet_ntop.m4 +++ b/gl/m4/inet_ntop.m4 @@ -1,5 +1,6 @@ -# inet_ntop.m4 serial 21 -dnl Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. +# inet_ntop.m4 +# serial 22 +dnl Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -36,14 +37,14 @@ AC_DEFUN([gl_FUNC_INET_NTOP], HAVE_DECL_INET_NTOP=0 fi else - gl_save_LIBS=$LIBS + gl_saved_LIBS=$LIBS AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [], [AC_CHECK_FUNCS([inet_ntop]) if test $ac_cv_func_inet_ntop = no; then HAVE_INET_NTOP=0 fi ]) - LIBS=$gl_save_LIBS + LIBS=$gl_saved_LIBS if test "$ac_cv_search_inet_ntop" != "no" \ && test "$ac_cv_search_inet_ntop" != "none required"; then diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4 index ef32e1b..72858ea 100644 --- a/gl/m4/intmax_t.m4 +++ b/gl/m4/intmax_t.m4 @@ -1,5 +1,6 @@ -# intmax_t.m4 serial 9 -dnl Copyright (C) 1997-2004, 2006-2007, 2009-2023 Free Software Foundation, +# intmax_t.m4 +# serial 9 +dnl Copyright (C) 1997-2004, 2006-2007, 2009-2024 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/inttypes.m4 b/gl/m4/inttypes.m4 index bf2eab2..c43cd16 100644 --- a/gl/m4/inttypes.m4 +++ b/gl/m4/inttypes.m4 @@ -1,5 +1,6 @@ -# inttypes.m4 serial 36 -dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. +# inttypes.m4 +# serial 37 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -170,6 +171,10 @@ AC_DEFUN([gl_INTTYPES_H_DEFAULTS], HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX]) HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX]) HAVE_IMAXDIV_T=1; AC_SUBST([HAVE_IMAXDIV_T]) + HAVE_IMAXABS=1; AC_SUBST([HAVE_IMAXABS]) + HAVE_IMAXDIV=1; AC_SUBST([HAVE_IMAXDIV]) + REPLACE_IMAXABS=0; AC_SUBST([REPLACE_IMAXABS]) + REPLACE_IMAXDIV=0; AC_SUBST([REPLACE_IMAXDIV]) REPLACE_STRTOIMAX=0; AC_SUBST([REPLACE_STRTOIMAX]) REPLACE_STRTOUMAX=0; AC_SUBST([REPLACE_STRTOUMAX]) INT32_MAX_LT_INTMAX_MAX=1; AC_SUBST([INT32_MAX_LT_INTMAX_MAX]) diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4 index 68c60e9..3b9da5b 100644 --- a/gl/m4/inttypes_h.m4 +++ b/gl/m4/inttypes_h.m4 @@ -1,5 +1,6 @@ -# inttypes_h.m4 serial 10 -dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc. +# inttypes_h.m4 +# serial 10 +dnl Copyright (C) 1997-2004, 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/iswblank.m4 b/gl/m4/iswblank.m4 new file mode 100644 index 0000000..4dc12d9 --- /dev/null +++ b/gl/m4/iswblank.m4 @@ -0,0 +1,39 @@ +# iswblank.m4 +# serial 7 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWBLANK], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + dnl Persuade glibc to declare iswblank(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + gl_CHECK_FUNCS_ANDROID([iswblank], [[#include ]]) + AC_CHECK_DECLS([iswblank], , , [[ + #include + #include + ]]) + if test $ac_cv_func_iswblank = no; then + HAVE_ISWBLANK=0 + if test $ac_cv_have_decl_iswblank = yes \ + || case "$gl_cv_onwards_func_iswblank" in \ + future*) true ;; \ + *) false ;; \ + esac; then + REPLACE_ISWBLANK=1 + fi + fi + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then + dnl Redefine all of iswcntrl, ..., towupper in . + : + else + if test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; then + dnl Redefine only iswblank. + : + fi + fi + +]) diff --git a/gl/m4/iswctype.m4 b/gl/m4/iswctype.m4 new file mode 100644 index 0000000..16031be --- /dev/null +++ b/gl/m4/iswctype.m4 @@ -0,0 +1,14 @@ +# iswctype.m4 +# serial 3 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWCTYPE], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + dnl Determine REPLACE_WCTYPE. + AC_REQUIRE([gl_FUNC_WCTYPE]) +]) diff --git a/gl/m4/iswdigit.m4 b/gl/m4/iswdigit.m4 new file mode 100644 index 0000000..999acd2 --- /dev/null +++ b/gl/m4/iswdigit.m4 @@ -0,0 +1,121 @@ +# iswdigit.m4 +# serial 7 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWDIGIT], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + AC_REQUIRE([gt_LOCALE_FR]) + AC_REQUIRE([gt_LOCALE_JA]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([gt_LOCALE_ZH_CN]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then + dnl redefines iswdigit already. + REPLACE_ISWDIGIT="$REPLACE_ISWCNTRL" + else + AC_CACHE_CHECK([whether iswdigit is ISO C compliant], + [gl_cv_func_iswdigit_works], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on FreeBSD, NetBSD, Solaris, native Windows. + freebsd* | dragonfly* | netbsd* | solaris* | mingw* | windows*) + gl_cv_func_iswdigit_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_iswdigit_works="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR != none || test $LOCALE_JA != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_ZH_CN != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include + +/* Returns the value of iswdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, s, n, &state); + if (ret != n) + abort (); + + return iswdigit (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + int result = 0; + + if (strcmp ("$LOCALE_FR", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR") != NULL) + { + /* This fails on mingw, MSVC 14. */ + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + if (!(is == 0)) + result |= 1; + } + if (strcmp ("$LOCALE_JA", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_JA") != NULL) + { + /* This fails on NetBSD 10.0. */ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + if (!(is == 0)) + result |= 2; + } + if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + /* This fails on FreeBSD 13.0, NetBSD 10.0, MSVC 14. */ + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + if (!(is == 0)) + result |= 4; + /* This fails on FreeBSD 13.0, NetBSD 10.0, MSVC 14. */ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + if (!(is == 0)) + result |= 8; + } + if (strcmp ("$LOCALE_ZH_CN", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + { + /* This fails on NetBSD 10.0, Solaris 10, Solaris 11.4. */ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + if (!(is == 0)) + result |= 16; + } + return result; +}]])], + [gl_cv_func_iswdigit_works=yes], + [gl_cv_func_iswdigit_works=no], + [:]) + fi + ]) + case "$gl_cv_func_iswdigit_works" in + *yes) ;; + *) REPLACE_ISWDIGIT=1 ;; + esac + fi +]) diff --git a/gl/m4/iswpunct.m4 b/gl/m4/iswpunct.m4 new file mode 100644 index 0000000..1edf58a --- /dev/null +++ b/gl/m4/iswpunct.m4 @@ -0,0 +1,49 @@ +# iswpunct.m4 +# serial 2 +dnl Copyright (C) 2023-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWPUNCT], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then + dnl redefines iswpunct already. + REPLACE_ISWPUNCT="$REPLACE_ISWCNTRL" + else + AC_CACHE_CHECK([whether iswpunct is consistent with ispunct], + [gl_cv_func_iswpunct_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int +main (int argc, char *argv[]) +{ + int result = 0; + /* This fails on Android 11. */ + if ((! iswpunct ('\`')) != (! ispunct ('\`'))) + result |= 1; + return result; +}]])], + [gl_cv_func_iswpunct_works=yes], + [gl_cv_func_iswpunct_works=no], + [case "$host_os" in + # Guess no on Android. + android*) gl_cv_func_iswpunct_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_iswpunct_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_iswpunct_works" in + *yes) ;; + *) REPLACE_ISWPUNCT=1 ;; + esac + fi +]) diff --git a/gl/m4/iswxdigit.m4 b/gl/m4/iswxdigit.m4 new file mode 100644 index 0000000..6085bf6 --- /dev/null +++ b/gl/m4/iswxdigit.m4 @@ -0,0 +1,111 @@ +# iswxdigit.m4 +# serial 7 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWXDIGIT], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + AC_REQUIRE([gt_LOCALE_JA]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([gt_LOCALE_ZH_CN]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then + dnl redefines iswxdigit already. + REPLACE_ISWXDIGIT="$REPLACE_ISWCNTRL" + else + AC_CACHE_CHECK([whether iswxdigit is ISO C compliant], + [gl_cv_func_iswxdigit_works], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on FreeBSD, NetBSD, Solaris, native Windows. + freebsd* | dragonfly* | netbsd* | solaris* | mingw* | windows*) + gl_cv_func_iswxdigit_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_iswxdigit_works="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_JA != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_ZH_CN != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include + +/* Returns the value of iswxdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, s, n, &state); + if (ret != n) + abort (); + + return iswxdigit (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + int result = 0; + + if (strcmp ("$LOCALE_JA", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_JA") != NULL) + { + /* This fails on NetBSD 10.0. */ + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\243\301", 2); + if (!(is == 0)) + result |= 1; + } + if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + /* This fails on FreeBSD 13.0. */ + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + if (!(is == 0)) + result |= 2; + /* This fails on NetBSD 10.0, MSVC 14. */ + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\357\274\241", 3); + if (!(is == 0)) + result |= 4; + } + if (strcmp ("$LOCALE_ZH_CN", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + { + /* This fails on Solaris 10, Solaris 11.4. */ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + if (!(is == 0)) + result |= 8; + } + return result; +}]])], + [gl_cv_func_iswxdigit_works=yes], + [gl_cv_func_iswxdigit_works=no], + [:]) + fi + ]) + case "$gl_cv_func_iswxdigit_works" in + *yes) ;; + *) REPLACE_ISWXDIGIT=1 ;; + esac + fi +]) diff --git a/gl/m4/langinfo_h.m4 b/gl/m4/langinfo_h.m4 index b17a526..5eee8a7 100644 --- a/gl/m4/langinfo_h.m4 +++ b/gl/m4/langinfo_h.m4 @@ -1,5 +1,6 @@ -# langinfo_h.m4 serial 12 -dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. +# langinfo_h.m4 +# serial 12 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/largefile.m4 b/gl/m4/largefile.m4 index 7fb81b8..2f82408 100644 --- a/gl/m4/largefile.m4 +++ b/gl/m4/largefile.m4 @@ -1,16 +1,18 @@ +# largefile.m4 +# serial 1 +dnl Copyright 1992-1996, 1998-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + # Enable large files on systems where this is not the default. # Enable support for files on Linux file systems with 64-bit inode numbers. -# Copyright 1992-1996, 1998-2023 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - # The following macro works around a problem in Autoconf's AC_FUNC_FSEEKO: # It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this # setting of _LARGEFILE_SOURCE is needed so that declares fseeko # and ftello in C++ mode as well. -# Fixed in Autoconf 2.72, which has AC_SYS_YEAR2038. +# This problem occurs in Autoconf 2.71 and earlier, which lack AC_SYS_YEAR2038. AC_DEFUN([gl_SET_LARGEFILE_SOURCE], m4_ifndef([AC_SYS_YEAR2038], [[ AC_REQUIRE([AC_CANONICAL_HOST]) @@ -24,29 +26,20 @@ AC_DEFUN([gl_SET_LARGEFILE_SOURCE], ]]) ) -# Work around a problem in autoconf <= 2.69: -# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, -# or configures them incorrectly in some cases. -m4_version_prereq([2.70], [], [ - -# _AC_SYS_LARGEFILE_TEST_INCLUDES -# ------------------------------- -m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], -[#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) - int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]];[]dnl -]) -])# m4_version_prereq 2.70 +dnl Remove AC_SYS_YEAR2038_RECOMMENDED if unpatched Autoconf 2.72 or earlier. +dnl Autoconf 2.72 still uses -n32, which is not a C preprocessor option, +dnl and which was useful only on IRIX which is no longer supported. +dnl This should be fixed in Autoconf 2.73. +m4_ifdef([AC_SYS_YEAR2038_RECOMMENDED], + [m4_bmatch(m4_ifdef([_AC_SYS_LARGEFILE_OPTIONS], + [m4_defn([_AC_SYS_LARGEFILE_OPTIONS])], + ["-n32"]), + ["-n32"], + [m4_undefine([AC_SYS_YEAR2038_RECOMMENDED])])]) -# Support AC_SYS_YEAR2038, even if Autoconf 2.71 or earlier. -# This code is taken from Autoconf master. -m4_ifndef([AC_SYS_YEAR2038], [ +m4_ifndef([AC_SYS_YEAR2038_RECOMMENDED], [ +# Fix up AC_SYS_YEAR2038_RECOMMENDED and related macros, even if +# unpatched Autoconf 2.72 or earlier. This code is taken from Autoconf master. # _AC_SYS_YEAR2038_TEST_CODE # -------------------------- @@ -78,8 +71,8 @@ m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize( dnl 32-bit MinGW (misconfiguration) )) -# _AC_SYS_YEAR2038_PROBE([IF-NOT-DETECTED]) -# ----------------------------------------- +# _AC_SYS_YEAR2038_PROBE +# ---------------------- # Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent # time points more than 2**31 - 1 seconds after the epoch (dates after # 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts @@ -92,13 +85,10 @@ m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize( # AC_TRY_RUN. Note also that some systems only support large time_t # together with large off_t. # -# If support is not detected, the behavior depends on which of the -# top-level AC_SYS_YEAR2038 macros was used (see below). -# # If you change this macro you may also need to change # _AC_SYS_YEAR2038_OPTIONS. AC_DEFUN([_AC_SYS_YEAR2038_PROBE], -[AC_CACHE_CHECK([for $CC option to enable timestamps after Jan 2038], +[AC_CACHE_CHECK([for $CPPFLAGS option for timestamps after 2038], [ac_cv_sys_year2038_opts], [ac_save_CPPFLAGS="$CPPFLAGS" ac_opt_found=no @@ -117,40 +107,20 @@ ac_have_year2038=yes AS_CASE([$ac_cv_sys_year2038_opts], ["none needed"], [], ["support not detected"], - [ac_have_year2038=no - AS_CASE([$enable_year2038], - [yes], - [# If we're not cross compiling and 'touch' works with a large - # timestamp, then we can presume the system supports wider time_t - # *somehow* and we just weren't able to detect it. One common - # case that we deliberately *don't* probe for is a system that - # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers - # wide time_t. (It would be inappropriate for us to override an - # intentional use of -m32.) Error out, demanding use of - # --disable-year2038 if this is intentional. - AS_IF([test $cross_compiling = no], - [AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null], - [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`], - [*'Feb 7 2106'* | *'Feb 7 17:10'*], - [AC_MSG_FAILURE(m4_text_wrap( - [this system appears to support timestamps after January 2038, - but no mechanism for enabling wide 'time_t' was detected. - Did you mean to build a 64-bit binary? (e.g. 'CC="${CC} -m64"'.) - To proceed with 32-bit time_t, configure with '--disable-year2038'.], - [], [], [55]))])])])])], + [ac_have_year2038=no], ["-D_TIME_BITS=64"], [AC_DEFINE([_TIME_BITS], [64], [Number of bits in time_t, on hosts where this is settable.])], - ["-D__MINGW_USE_VC2005_COMPAT=1"], + ["-D__MINGW_USE_VC2005_COMPAT"], [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1], [Define to 1 on platforms where this makes time_t a 64-bit type.])], ["-U_USE_32_BIT_TIME_T"*], [AC_MSG_FAILURE(m4_text_wrap( [the 'time_t' type is currently forced to be 32-bit. - It will stop working after January 2038. + It will stop working after mid-January 2038. Remove _USE_32BIT_TIME_T from the compiler flags.], [], [], [55]))], @@ -160,12 +130,11 @@ AS_CASE([$ac_cv_sys_year2038_opts], # _AC_SYS_YEAR2038_ENABLE # ----------------------- -# Subroutine of AC_SYS_YEAR2038 and _AC_SYS_YEAR2038_OPT_IN. # Depending on which of the YEAR2038 macros was used, add either an -# --enable-year2038, or a --disable-year2038, or no option at all to -# the configure script. Note that this is expanded very late and +# --enable-year2038 or a --disable-year2038 to +# the configure script. This is expanded very late and # therefore there cannot be any code in the AC_ARG_ENABLE. The -# default value for enable_year2038 is emitted unconditionally +# default value for 'enable_year2038' is emitted unconditionally # because the generated code always looks at this variable. m4_define([_AC_SYS_YEAR2038_ENABLE], [m4_divert_text([DEFAULTS], @@ -175,50 +144,70 @@ m4_define([_AC_SYS_YEAR2038_ENABLE], [AC_ARG_ENABLE([year2038], m4_provide_if([AC_SYS_YEAR2038], [AS_HELP_STRING([--disable-year2038], - [do not support timestamps after 2038])], + [don't support timestamps after 2038])], [AS_HELP_STRING([--enable-year2038], [support timestamps after 2038])]))]) -# _AC_SYS_YEAR2038_OPT_IN -# ----------------------- -# If the --enable-year2038 option is given to configure, attempt to -# detect and activate support for large time_t on 32-bit systems. -# This macro is automatically invoked by AC_SYS_LARGEFILE when large -# *file* support is detected. It does not AC_REQUIRE AC_SYS_LARGEFILE -# to avoid a dependency loop, and is therefore unsafe to expose as a -# documented macro. -AC_DEFUN([_AC_SYS_YEAR2038_OPT_IN], -[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl - AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE]) - AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE]) -])]) - # AC_SYS_YEAR2038 # --------------- # Attempt to detect and activate support for large time_t. # On systems where time_t is not always 64 bits, this probe can be # skipped by passing the --disable-year2038 option to configure. AC_DEFUN([AC_SYS_YEAR2038], -[AC_REQUIRE([AC_SYS_LARGEFILE])]dnl -[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl - AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE]) - AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE]) -])]) +[AC_REQUIRE([AC_SYS_LARGEFILE])dnl +AS_IF([test "$enable_year2038,$ac_have_year2038,$cross_compiling" = yes,no,no], + [# If we're not cross compiling and 'touch' works with a large + # timestamp, then we can presume the system supports wider time_t + # *somehow* and we just weren't able to detect it. One common + # case that we deliberately *don't* probe for is a system that + # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers + # wide time_t. (It would be inappropriate for us to override an + # intentional use of -m32.) Error out, demanding use of + # --disable-year2038 if this is intentional. + AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null], + [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`], + [*'Feb 7 2106'* | *'Feb 7 17:10'*], + [AC_MSG_FAILURE(m4_text_wrap( + [this system appears to support timestamps after mid-January 2038, + but no mechanism for enabling wide 'time_t' was detected. + Did you mean to build a 64-bit binary? (E.g., 'CC="${CC} -m64"'.) + To proceed with 32-bit time_t, configure with '--disable-year2038'.], + [], [], [55]))])])])]) + +# AC_SYS_YEAR2038_RECOMMENDED +# --------------------------- +# Same as AC_SYS_YEAR2038, but recommend support for large time_t. +# If we cannot find any way to make time_t capable of representing +# values larger than 2**31 - 1, error out unless --disable-year2038 is given. +AC_DEFUN([AC_SYS_YEAR2038_RECOMMENDED], +[AC_REQUIRE([AC_SYS_YEAR2038])dnl +AS_IF([test "$enable_year2038,$ac_have_year2038" = yes,no], + [AC_MSG_FAILURE(m4_text_wrap( + [could not enable timestamps after mid-January 2038. + This package recommends support for these later timestamps. + However, to proceed with signed 32-bit time_t even though it + will fail then, configure with '--disable-year2038'.], + [], [], [55]))])]) # _AC_SYS_LARGEFILE_TEST_CODE # --------------------------- # C code used to probe for large file support. m4_define([_AC_SYS_LARGEFILE_TEST_CODE], [@%:@include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, +@%:@ifndef FTYPE +@%:@ define FTYPE off_t +@%:@endif + /* Check that FTYPE can represent 2**63 - 1 correctly. + We can't simply define LARGE_FTYPE to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -@%:@define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) - int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) +@%:@define LARGE_FTYPE (((FTYPE) 1 << 31 << 31) - 1 + ((FTYPE) 1 << 31 << 31)) + int FTYPE_is_large[[(LARGE_FTYPE % 2147483629 == 721 + && LARGE_FTYPE % 2147483647 == 1) ? 1 : -1]];[]dnl ]) +# Defined by Autoconf 2.71 and circa 2022 Gnulib unwisely depended on it. +m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], [_AC_SYS_LARGEFILE_TEST_CODE]) # _AC_SYS_LARGEFILE_OPTIONS # ------------------------- @@ -228,8 +217,7 @@ m4_define([_AC_SYS_LARGEFILE_TEST_CODE], m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize( ["none needed"] dnl Most current systems ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec - ["-D_LARGE_FILES=1"] dnl AIX (which versions?) - ["-n32"] dnl Irix 6.2 w/ SGI compiler + ["-D_LARGE_FILES=1"] dnl 32-bit AIX 4.2.1+, 32-bit z/OS )) # _AC_SYS_LARGEFILE_PROBE @@ -246,24 +234,43 @@ m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize( # If you change this macro you may also need to change # _AC_SYS_LARGEFILE_OPTIONS. AC_DEFUN([_AC_SYS_LARGEFILE_PROBE], -[AC_CACHE_CHECK([for $CC option to enable large file support], +[AC_CACHE_CHECK([for $CPPFLAGS option for large files], [ac_cv_sys_largefile_opts], - [ac_save_CC="$CC" + [ac_save_CPPFLAGS=$CPPFLAGS ac_opt_found=no for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do AS_IF([test x"$ac_opt" != x"none needed"], - [CC="$ac_save_CC $ac_opt"]) + [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])], - [ac_cv_sys_largefile_opts="$ac_opt" + [AS_IF([test x"$ac_opt" = x"none needed"], + [# GNU/Linux s390x and alpha need _FILE_OFFSET_BITS=64 for wide ino_t. + CPPFLAGS="$CPPFLAGS -DFTYPE=ino_t" + AC_COMPILE_IFELSE([], [], + [CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64" + AC_COMPILE_IFELSE([], [ac_opt='-D_FILE_OFFSET_BITS=64'])])]) + ac_cv_sys_largefile_opts=$ac_opt ac_opt_found=yes]) test $ac_opt_found = no || break done - CC="$ac_save_CC" + CPPFLAGS=$ac_save_CPPFLAGS + dnl Gnulib implements large file support for native Windows, based on the + dnl variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE. + m4_ifdef([gl_LARGEFILE], [ + AC_REQUIRE([AC_CANONICAL_HOST]) + if test $ac_opt_found != yes; then + AS_CASE([$host_os], + [mingw* | windows*], + [ac_cv_sys_largefile_opts="supported through gnulib" + ac_opt_found=yes] + ) + fi + ]) test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"]) ac_have_largefile=yes AS_CASE([$ac_cv_sys_largefile_opts], ["none needed"], [], + ["supported through gnulib"], [], ["support not detected"], [ac_have_largefile=no], @@ -275,27 +282,12 @@ AS_CASE([$ac_cv_sys_largefile_opts], [AC_DEFINE([_LARGE_FILES], [1], [Define to 1 on platforms where this makes off_t a 64-bit type.])], - ["-n32"], - [CC="$CC -n32"], - [AC_MSG_ERROR( [internal error: bad value for \$ac_cv_sys_largefile_opts])]) -_AC_SYS_YEAR2038_OPT_IN -]) - -# _AC_SYS_LARGEFILE_ENABLE -# ------------------------ -# Subroutine of AC_SYS_LARGEFILE. Note that this -# is expanded very late and therefore there cannot be any code in the -# AC_ARG_ENABLE. The default value for enable_largefile is emitted -# unconditionally because the generated shell code always looks at -# this variable. -m4_define([_AC_SYS_LARGEFILE_ENABLE], -[m4_divert_text([DEFAULTS], - enable_largefile=yes)]dnl -[AC_ARG_ENABLE([largefile], - [AS_HELP_STRING([--disable-largefile], [omit support for large files])])]) +AS_IF([test "$enable_year2038" != no], + [_AC_SYS_YEAR2038_PROBE]) +AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])]) # AC_SYS_LARGEFILE # ---------------- @@ -306,14 +298,13 @@ m4_define([_AC_SYS_LARGEFILE_ENABLE], # Additionally, on Linux file systems with 64-bit inodes a file that happens # to have a 64-bit inode number cannot be accessed by 32-bit applications on # Linux x86/x86_64. This can occur with file systems such as XFS and NFS. -# This macro allows configuration to continue if the system doesn't support -# large files. AC_DEFUN([AC_SYS_LARGEFILE], -[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl - AS_IF([test "$enable_largefile" != no], [_AC_SYS_LARGEFILE_PROBE]) - AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE]) -])]) -])# m4_ifndef AC_SYS_YEAR2038 +[AC_ARG_ENABLE([largefile], + [AS_HELP_STRING([--disable-largefile], + [omit support for large files])])dnl +AS_IF([test "$enable_largefile,$enable_year2038" != no,no], + [_AC_SYS_LARGEFILE_PROBE])]) +])# m4_ifndef AC_SYS_YEAR2038_RECOMMENDED # Enable large files on systems where this is implemented by Gnulib, not by the # system headers. @@ -323,7 +314,7 @@ AC_DEFUN([gl_LARGEFILE], [ AC_REQUIRE([AC_CANONICAL_HOST]) case "$host_os" in - mingw*) + mingw* | windows*) dnl Native Windows. dnl mingw64 defines off_t to a 64-bit type already, if dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE. diff --git a/gl/m4/limits-h.m4 b/gl/m4/limits-h.m4 index 5088fa1..1b619e1 100644 --- a/gl/m4/limits-h.m4 +++ b/gl/m4/limits-h.m4 @@ -1,10 +1,12 @@ -dnl Check whether limits.h has needed features. - -dnl Copyright 2016-2023 Free Software Foundation, Inc. +# limits-h.m4 +# serial 1 +dnl Copyright 2016-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl Check whether limits.h has needed features. + dnl From Paul Eggert. AC_DEFUN_ONCE([gl_LIMITS_H], @@ -23,14 +25,27 @@ AC_DEFUN_ONCE([gl_LIMITS_H], int wb = WORD_BIT; int ullw = ULLONG_WIDTH; int bw = BOOL_WIDTH; + int bm = BOOL_MAX; + int mblm = MB_LEN_MAX; ]])], [gl_cv_header_limits_width=yes], [gl_cv_header_limits_width=no])]) - if test "$gl_cv_header_limits_width" = yes; then - GL_GENERATE_LIMITS_H=false - else - GL_GENERATE_LIMITS_H=true - fi + GL_GENERATE_LIMITS_H=true + AS_IF([test "$gl_cv_header_limits_width" = yes], + [AC_CACHE_CHECK([whether limits.h has SSIZE_MAX], + [gl_cv_header_limits_ssize_max], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#include + #ifndef SSIZE_MAX + #error "SSIZE_MAX is not defined" + #endif + ]])], + [gl_cv_header_limits_ssize_max=yes], + [gl_cv_header_limits_ssize_max=no])]) + if test "$gl_cv_header_limits_ssize_max" = yes; then + GL_GENERATE_LIMITS_H=false + fi]) ]) dnl Unconditionally enables the replacement of . diff --git a/gl/m4/localcharset.m4 b/gl/m4/localcharset.m4 index 15b6b2a..807a5ee 100644 --- a/gl/m4/localcharset.m4 +++ b/gl/m4/localcharset.m4 @@ -1,5 +1,6 @@ -# localcharset.m4 serial 8 -dnl Copyright (C) 2002, 2004, 2006, 2009-2023 Free Software Foundation, Inc. +# localcharset.m4 +# serial 8 +dnl Copyright (C) 2002, 2004, 2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/locale-fr.m4 b/gl/m4/locale-fr.m4 index 8c41fad..f8d7c54 100644 --- a/gl/m4/locale-fr.m4 +++ b/gl/m4/locale-fr.m4 @@ -1,5 +1,6 @@ -# locale-fr.m4 serial 20 -dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc. +# locale-fr.m4 +# serial 23 +dnl Copyright (C) 2003, 2005-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -7,7 +8,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Determine the name of a french locale with traditional encoding. -AC_DEFUN([gt_LOCALE_FR], +AC_DEFUN_ONCE([gt_LOCALE_FR], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AM_LANGINFO_CODESET]) @@ -86,7 +87,7 @@ int main () { # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", # "ja" as "Japanese" or "Japanese_Japan.932", # and similar. - mingw*) + mingw* | windows*) # Test for the native Windows locale name. if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr=French_France.1252 @@ -116,7 +117,7 @@ int main () { if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr=fr_FR.iso88591 else - # Test for the Solaris 7 locale name. + # Test for the Solaris 10 locale name. if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr=fr else @@ -133,15 +134,31 @@ int main () { rm -fr conftest* ]) LOCALE_FR=$gt_cv_locale_fr + case $LOCALE_FR in #( + '' | *[[[:space:]\"\$\'*@<:@]]*) + dnl This locale name might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_FR"; assuming "none"]) + LOCALE_FR=none;; + esac AC_SUBST([LOCALE_FR]) ]) dnl Determine the name of a french locale with UTF-8 encoding. -AC_DEFUN([gt_LOCALE_FR_UTF8], +AC_DEFUN_ONCE([gt_LOCALE_FR_UTF8], [ + AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AM_LANGINFO_CODESET]) AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ - AC_LANG_CONFTEST([AC_LANG_SOURCE([[ + case "$host_os" in + *-musl* | midipix*) + dnl On musl libc, all kinds of ll_CC.UTF-8 locales exist, even without + dnl any locale file on disk. But they are effectively equivalent to the + dnl C.UTF-8 locale, except for locale categories (such as LC_MESSSAGES) + dnl for which localizations (.mo files) have been installed. + gt_cv_locale_fr_utf8=fr_FR.UTF-8 + ;; + *) + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ #include #include #if HAVE_LANGINFO_CODESET @@ -203,51 +220,82 @@ int main () { #endif return 0; } - ]])]) - if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then - case "$host_os" in - # Handle native Windows specially, because there setlocale() interprets - # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", - # "fr" or "fra" as "French" or "French_France.1252", - # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", - # "ja" as "Japanese" or "Japanese_Japan.932", - # and similar. - mingw*) - # Test for the hypothetical native Windows locale name. - if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr_utf8=French_France.65001 - else - # None found. - gt_cv_locale_fr_utf8=none - fi - ;; - *) - # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because - # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the - # configure script would override the LC_ALL setting. Likewise for - # LC_CTYPE, which is also set at the beginning of the configure script. - # Test for the usual locale name. - if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr_utf8=fr_FR - else - # Test for the locale name with explicit encoding suffix. - if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr_utf8=fr_FR.UTF-8 - else - # Test for the Solaris 7 locale name. - if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr_utf8=fr.UTF-8 + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + case "$host_os" in + # Handle native Windows specially, because there setlocale() interprets + # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", + # "fr" or "fra" as "French" or "French_France.1252", + # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", + # "ja" as "Japanese" or "Japanese_Japan.932", + # and similar. + mingw* | windows*) + # Test for the hypothetical native Windows locale name. + if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=French_France.65001 else # None found. gt_cv_locale_fr_utf8=none fi - fi - fi - ;; - esac - fi - rm -fr conftest* + ;; + *) + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the usual locale name. + if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr_FR + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr_FR.UTF-8 + else + # Test for the Solaris 10 locale name. + if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr.UTF-8 + else + # None found. + gt_cv_locale_fr_utf8=none + fi + fi + fi + ;; + esac + fi + rm -fr conftest* + ;; + esac ]) LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 + case $LOCALE_FR_UTF8 in #( + '' | *[[[:space:]\"\$\'*@<:@]]*) + dnl This locale name might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_FR_UTF8"; assuming "none"]) + LOCALE_FR_UTF8=none;; + esac AC_SUBST([LOCALE_FR_UTF8]) + + dnl Users of $LOCALE_FR_UTF8 need to know which of the locale categories they + dnl can rely on. + case "$host_os" in + *-musl* | midipix*) + dnl On musl libc, locale categories other than LC_CTYPE and LC_MESSAGES + dnl are effectively unimplemented. + LC_COLLATE_IMPLEMENTED=false + LC_NUMERIC_IMPLEMENTED=false + LC_TIME_IMPLEMENTED=false + LC_MONETARY_IMPLEMENTED=false + ;; + *) + LC_COLLATE_IMPLEMENTED=true + LC_NUMERIC_IMPLEMENTED=true + LC_TIME_IMPLEMENTED=true + LC_MONETARY_IMPLEMENTED=true + ;; + esac + AC_SUBST([LC_COLLATE_IMPLEMENTED]) + AC_SUBST([LC_NUMERIC_IMPLEMENTED]) + AC_SUBST([LC_TIME_IMPLEMENTED]) + AC_SUBST([LC_MONETARY_IMPLEMENTED]) ]) diff --git a/gl/m4/locale-ja.m4 b/gl/m4/locale-ja.m4 index 2590173..8423bcb 100644 --- a/gl/m4/locale-ja.m4 +++ b/gl/m4/locale-ja.m4 @@ -1,5 +1,6 @@ -# locale-ja.m4 serial 15 -dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc. +# locale-ja.m4 +# serial 18 +dnl Copyright (C) 2003, 2005-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -7,7 +8,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Determine the name of a japanese locale with EUC-JP encoding. -AC_DEFUN([gt_LOCALE_JA], +AC_DEFUN_ONCE([gt_LOCALE_JA], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AM_LANGINFO_CODESET]) @@ -90,7 +91,7 @@ int main () # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", # "ja" as "Japanese" or "Japanese_Japan.932", # and similar. - mingw*) + mingw* | windows*) # Note that on native Windows, the Japanese locale is # Japanese_Japan.932, and CP932 is very different from EUC-JP, so we # cannot use it here. @@ -117,7 +118,7 @@ int main () if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_ja=ja_JP.EUC else - # Test for the Solaris 7 locale name. + # Test for the Solaris 10 locale name. if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_ja=ja else @@ -139,5 +140,11 @@ int main () rm -fr conftest* ]) LOCALE_JA=$gt_cv_locale_ja + case $LOCALE_JA in #( + '' | *[[[:space:]\"\$\'*@<:@]]*) + dnl This locale name might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_JA"; assuming "none"]) + LOCALE_JA=none;; + esac AC_SUBST([LOCALE_JA]) ]) diff --git a/gl/m4/locale-zh.m4 b/gl/m4/locale-zh.m4 index b9f9eef..7f1a10b 100644 --- a/gl/m4/locale-zh.m4 +++ b/gl/m4/locale-zh.m4 @@ -1,5 +1,6 @@ -# locale-zh.m4 serial 15 -dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc. +# locale-zh.m4 +# serial 18 +dnl Copyright (C) 2003, 2005-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -7,7 +8,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Determine the name of a chinese locale with GB18030 encoding. -AC_DEFUN([gt_LOCALE_ZH_CN], +AC_DEFUN_ONCE([gt_LOCALE_ZH_CN], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AM_LANGINFO_CODESET]) @@ -91,7 +92,7 @@ int main () # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", # "ja" as "Japanese" or "Japanese_Japan.932", # and similar. - mingw*) + mingw* | windows*) # Test for the hypothetical native Windows locale name. if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_zh_CN=Chinese_China.54936 @@ -133,5 +134,11 @@ int main () rm -fr conftest* ]) LOCALE_ZH_CN=$gt_cv_locale_zh_CN + case $LOCALE_ZH_CN in #( + '' | *[[[:space:]\"\$\'*@<:@]]*) + dnl This locale name might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_ZH_CN"; assuming "none"]) + LOCALE_ZH_CN=none;; + esac AC_SUBST([LOCALE_ZH_CN]) ]) diff --git a/gl/m4/locale_h.m4 b/gl/m4/locale_h.m4 index a33a0a4..cd1c81e 100644 --- a/gl/m4/locale_h.m4 +++ b/gl/m4/locale_h.m4 @@ -1,5 +1,6 @@ -# locale_h.m4 serial 28 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# locale_h.m4 +# serial 31 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -59,7 +60,9 @@ AC_DEFUN_ONCE([gl_LOCALE_H], dnl On native Windows with MSVC, merely define these member names as macros. dnl This avoids trouble in C++ mode. case "$host_os" in - mingw*) + windows*-msvc*) + ;; + mingw* | windows*) AC_EGREP_CPP([Special], [ #ifdef _MSC_VER Special @@ -152,7 +155,7 @@ AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE]) - gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME_UNSAFE]) ]) m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS]) AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) diff --git a/gl/m4/localeconv.m4 b/gl/m4/localeconv.m4 index ae225fe..77d5684 100644 --- a/gl/m4/localeconv.m4 +++ b/gl/m4/localeconv.m4 @@ -1,5 +1,6 @@ -# localeconv.m4 serial 1 -dnl Copyright (C) 2012-2023 Free Software Foundation, Inc. +# localeconv.m4 +# serial 3 +dnl Copyright (C) 2012-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -8,10 +9,45 @@ AC_DEFUN([gl_FUNC_LOCALECONV], [ AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) AC_REQUIRE([gl_LOCALE_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles if test $REPLACE_STRUCT_LCONV = 1; then REPLACE_LOCALECONV=1 fi + if test $REPLACE_LOCALECONV = 0; then + dnl Test whether fields of type 'char' are filled correctly. + dnl This test fails on mingw 5.0.3. + AC_CACHE_CHECK([whether localeconv works], + [gl_cv_func_localeconv_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + #include + int main () + { + struct lconv *l = localeconv (); + return l->frac_digits != CHAR_MAX && l->frac_digits < 0; + } + ]])], + [gl_cv_func_localeconv_works=yes], + [gl_cv_func_localeconv_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_localeconv_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_localeconv_works="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_localeconv_works="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_localeconv_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_localeconv_works" in + *yes) ;; + *) REPLACE_LOCALECONV=1 ;; + esac + fi ]) # Prerequisites of lib/localeconv.c. @@ -19,4 +55,6 @@ AC_DEFUN([gl_PREREQ_LOCALECONV], [ AC_CHECK_MEMBERS([struct lconv.decimal_point], [], [], [[#include ]]) + AC_CHECK_MEMBERS([struct lconv.int_p_cs_precedes], [], [], + [[#include ]]) ]) diff --git a/gl/m4/lock.m4 b/gl/m4/lock.m4 index 88cf557..eb0fc6a 100644 --- a/gl/m4/lock.m4 +++ b/gl/m4/lock.m4 @@ -1,5 +1,6 @@ -# lock.m4 serial 14 -dnl Copyright (C) 2005-2023 Free Software Foundation, Inc. +# lock.m4 +# serial 14 +dnl Copyright (C) 2005-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4 index fd4f1f2..0bc3d65 100644 --- a/gl/m4/lseek.m4 +++ b/gl/m4/lseek.m4 @@ -1,5 +1,6 @@ -# lseek.m4 serial 12 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# lseek.m4 +# serial 15 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -13,13 +14,15 @@ AC_DEFUN([gl_FUNC_LSEEK], AC_CHECK_HEADERS_ONCE([unistd.h]) AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe], [case "$host_os" in - mingw*) + mingw* | windows*) dnl Native Windows. dnl The result of lseek (fd, (off_t)0, SEEK_CUR) or dnl SetFilePointer(handle, 0, NULL, FILE_CURRENT) - dnl for a pipe depends on the environment: In a Cygwin 1.5 - dnl environment it succeeds (wrong); in a Cygwin 1.7 environment - dnl it fails with a wrong errno value. + dnl for a pipe depends on the environment: + dnl In a Cygwin 1.5 environment it succeeds (wrong); + dnl in a Cygwin 1.7 environment it fails with a wrong errno value; + dnl in a Cygwin 2.9.0 environment it fails correctly; + dnl in a Cygwin 3.4.6 environment it succeeds again (wrong). gl_cv_func_lseek_pipe=no ;; *) @@ -70,9 +73,29 @@ AC_DEFUN([gl_FUNC_LSEEK], REPLACE_LSEEK=1 fi - dnl macOS SEEK_DATA is incompatible with other platforms. - case $host_os in - darwin*) - REPLACE_LSEEK=1;; - esac + AS_IF([test $REPLACE_LSEEK = 0], + [AC_CACHE_CHECK([whether SEEK_DATA works but is incompatible with GNU], + [gl_cv_func_lseek_works_but_incompatible], + [AC_PREPROC_IFELSE( + [AC_LANG_SOURCE( + dnl Use macOS "9999" to stand for a future fixed macOS version. + dnl See ../lib/unistd.in.h and . + [[#include + #if defined __APPLE__ && defined __MACH__ && defined SEEK_DATA + # ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + # include + # endif + # if 99990000 <= MAC_OS_X_VERSION_MIN_REQUIRED + # define LSEEK_WORKS_BUT_IS_INCOMPATIBLE_WITH_GNU + # endif + #endif + #ifndef LSEEK_WORKS_BUT_IS_INCOMPATIBLE_WITH_GNU + #error "No need to work around the bug" + #endif + ]])], + [gl_cv_func_lseek_works_but_incompatible=yes], + [gl_cv_func_lseek_works_but_incompatible=no])]) + if test "$gl_cv_func_lseek_works_but_incompatible" = yes; then + REPLACE_LSEEK=1 + fi]) ]) diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4 index 5540292..41a4693 100644 --- a/gl/m4/malloc.m4 +++ b/gl/m4/malloc.m4 @@ -1,5 +1,6 @@ -# malloc.m4 serial 28 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# malloc.m4 +# serial 31 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -16,7 +17,8 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF], [[#include ]], [[void *p = malloc (0); - int result = !p; + void * volatile vp = p; + int result = !vp; free (p); return result;]]) ], @@ -25,8 +27,8 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF], [case "$host_os" in # Guess yes on platforms where we know the result. *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ - | gnu* | *-musl* | midnightbsd* \ - | hpux* | solaris* | cygwin* | mingw* | msys* ) + | gnu* | *-musl* | midipix* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | windows* | msys* ) ac_cv_func_malloc_0_nonnull="guessing yes" ;; # If we don't know, obey --enable-cross-guesses. *) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;; @@ -128,7 +130,7 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX], dnl except on those platforms where we have seen 'test-malloc-gnu', dnl 'test-realloc-gnu', 'test-calloc-gnu' fail. case "$host_os" in - mingw*) + mingw* | windows*) gl_cv_func_malloc_posix=no ;; irix* | solaris*) dnl On IRIX 6.5, the three functions return NULL with errno unset diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4 index 1d777eb..9e09d22 100644 --- a/gl/m4/malloca.m4 +++ b/gl/m4/malloca.m4 @@ -1,5 +1,6 @@ -# malloca.m4 serial 2 -dnl Copyright (C) 2003-2004, 2006-2007, 2009-2023 Free Software Foundation, +# malloca.m4 +# serial 2 +dnl Copyright (C) 2003-2004, 2006-2007, 2009-2024 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4 index d2e90ff..4b26c9e 100644 --- a/gl/m4/math_h.m4 +++ b/gl/m4/math_h.m4 @@ -1,5 +1,6 @@ -# math_h.m4 serial 125 -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# math_h.m4 +# serial 138 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -42,15 +43,21 @@ AC_DEFUN_ONCE([gl_MATH_H], cbrt cbrtf cbrtl ceilf ceill copysign copysignf copysignl cosf cosl coshf expf expl exp2 exp2f exp2l expm1 expm1f expm1l fabsf fabsl floorf floorl fma fmaf fmal - fmod fmodf fmodl frexpf frexpl hypotf hypotl + fmod fmodf fmodl frexpf frexpl + getpayload getpayloadf getpayloadl + hypotf hypotl ilogb ilogbf ilogbl ldexpf ldexpl log logf logl log10 log10f log10l log1p log1pf log1pl log2 log2f log2l logb logbf logbl modf modff modfl powf remainder remainderf remainderl - rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl - tanf tanl tanhf trunc truncf truncl]) + rint rintf rintl round roundf roundl + setpayload setpayloadf setpayloadl + setpayloadsig setpayloadsigf setpayloadsigl + sinf sinl sinhf sqrtf sqrtl + tanf tanl tanhf totalorder totalorderf totalorderl totalordermag + totalordermagf totalordermagl trunc truncf truncl]) ]) # gl_MATH_MODULE_INDICATOR([modulename]) @@ -113,6 +120,9 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXP]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAYLOAD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAYLOADF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAYLOADL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTL]) @@ -125,6 +135,7 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAND]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXP]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG]) @@ -155,6 +166,12 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUND]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOAD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADSIG]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADSIGF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADSIGL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNBIT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINL]) @@ -164,6 +181,12 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANHF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDER]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERMAG]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERMAGF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERMAGL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNC]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCL]) @@ -209,6 +232,9 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], HAVE_FMODF=1; AC_SUBST([HAVE_FMODF]) HAVE_FMODL=1; AC_SUBST([HAVE_FMODL]) HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF]) + HAVE_GETPAYLOAD=1; AC_SUBST([HAVE_GETPAYLOAD]) + HAVE_GETPAYLOADF=1; AC_SUBST([HAVE_GETPAYLOADF]) + HAVE_GETPAYLOADL=1; AC_SUBST([HAVE_GETPAYLOADL]) HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF]) HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL]) HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB]) @@ -234,6 +260,12 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF]) HAVE_RINT=1; AC_SUBST([HAVE_RINT]) HAVE_RINTL=1; AC_SUBST([HAVE_RINTL]) + HAVE_SETPAYLOAD=1; AC_SUBST([HAVE_SETPAYLOAD]) + HAVE_SETPAYLOADF=1; AC_SUBST([HAVE_SETPAYLOADF]) + HAVE_SETPAYLOADL=1; AC_SUBST([HAVE_SETPAYLOADL]) + HAVE_SETPAYLOADSIG=1; AC_SUBST([HAVE_SETPAYLOADSIG]) + HAVE_SETPAYLOADSIGF=1; AC_SUBST([HAVE_SETPAYLOADSIGF]) + HAVE_SETPAYLOADSIGL=1; AC_SUBST([HAVE_SETPAYLOADSIGL]) HAVE_SINF=1; AC_SUBST([HAVE_SINF]) HAVE_SINL=1; AC_SUBST([HAVE_SINL]) HAVE_SINHF=1; AC_SUBST([HAVE_SINHF]) @@ -242,6 +274,12 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], HAVE_TANF=1; AC_SUBST([HAVE_TANF]) HAVE_TANL=1; AC_SUBST([HAVE_TANL]) HAVE_TANHF=1; AC_SUBST([HAVE_TANHF]) + HAVE_TOTALORDER=1; AC_SUBST([HAVE_TOTALORDER]) + HAVE_TOTALORDERF=1; AC_SUBST([HAVE_TOTALORDERF]) + HAVE_TOTALORDERL=1; AC_SUBST([HAVE_TOTALORDERL]) + HAVE_TOTALORDERMAG=1; AC_SUBST([HAVE_TOTALORDERMAG]) + HAVE_TOTALORDERMAGF=1; AC_SUBST([HAVE_TOTALORDERMAGF]) + HAVE_TOTALORDERMAGL=1; AC_SUBST([HAVE_TOTALORDERMAGL]) HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) @@ -309,6 +347,9 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF]) REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) + REPLACE_GETPAYLOAD=0; AC_SUBST([REPLACE_GETPAYLOAD]) + REPLACE_GETPAYLOADF=0; AC_SUBST([REPLACE_GETPAYLOADF]) + REPLACE_GETPAYLOADL=0; AC_SUBST([REPLACE_GETPAYLOADL]) REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL]) REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT]) REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF]) @@ -319,6 +360,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF]) REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN]) + REPLACE_LDEXP=0; AC_SUBST([REPLACE_LDEXP]) REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) REPLACE_LOG=0; AC_SUBST([REPLACE_LOG]) REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF]) @@ -354,6 +396,12 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) REPLACE_TANF=0; AC_SUBST([REPLACE_TANF]) REPLACE_TANHF=0; AC_SUBST([REPLACE_TANHF]) + REPLACE_TOTALORDER=0; AC_SUBST([REPLACE_TOTALORDER]) + REPLACE_TOTALORDERF=0; AC_SUBST([REPLACE_TOTALORDERF]) + REPLACE_TOTALORDERL=0; AC_SUBST([REPLACE_TOTALORDERL]) + REPLACE_TOTALORDERMAG=0; AC_SUBST([REPLACE_TOTALORDERMAG]) + REPLACE_TOTALORDERMAGF=0; AC_SUBST([REPLACE_TOTALORDERMAGF]) + REPLACE_TOTALORDERMAGL=0; AC_SUBST([REPLACE_TOTALORDERMAGL]) REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC]) REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF]) REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) @@ -364,7 +412,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], # Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines # HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly. # The currently known platforms where this is the case are: -# Linux/HPPA, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9. +# Linux/HPPA, NetBSD/sparc32, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9. AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE], [ AC_CACHE_CHECK([whether long double and double are the same], diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4 index bb39304..62c4fdb 100644 --- a/gl/m4/mbrtowc.m4 +++ b/gl/m4/mbrtowc.m4 @@ -1,5 +1,6 @@ -# mbrtowc.m4 serial 38 -*- coding: utf-8 -*- -dnl Copyright (C) 2001-2002, 2004-2005, 2008-2023 Free Software Foundation, +# mbrtowc.m4 +# serial 44 -*- coding: utf-8 -*- +dnl Copyright (C) 2001-2002, 2004-2005, 2008-2024 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -91,20 +92,25 @@ AC_DEFUN([gl_FUNC_MBRTOWC], fi if test $REPLACE_MBSTATE_T = 1; then case "$host_os" in - mingw*) LIB_MBRTOWC= ;; + mingw* | windows*) + MBRTOWC_LIB= + ;; *) gl_WEAK_SYMBOLS case "$gl_cv_have_weak" in - *yes) LIB_MBRTOWC= ;; - *) LIB_MBRTOWC="$LIBPTHREAD" ;; + *yes) MBRTOWC_LIB= ;; + *) MBRTOWC_LIB="$LIBPTHREAD" ;; esac ;; esac else - LIB_MBRTOWC= + MBRTOWC_LIB= fi - dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX + dnl MBRTOWC_LIB is expected to be '-pthread' or '-lpthread' on AIX dnl with gcc or xlc, and empty otherwise. + AC_SUBST([MBRTOWC_LIB]) + dnl For backward compatibility. + LIB_MBRTOWC="$MBRTOWC_LIB" AC_SUBST([LIB_MBRTOWC]) ]) @@ -114,7 +120,7 @@ dnl Result is REPLACE_MBSTATE_T. dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to dnl avoid inconsistencies. -AC_DEFUN([gl_MBSTATE_T_BROKEN], +AC_DEFUN_ONCE([gl_MBSTATE_T_BROKEN], [ AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) @@ -126,7 +132,7 @@ AC_DEFUN([gl_MBSTATE_T_BROKEN], dnl to override it, even if - like on MSVC - mbsinit() is only defined as dnl an inline function, not as a global function. if case "$host_os" in - mingw*) true ;; + mingw* | windows*) true ;; *) test $ac_cv_func_mbsinit = yes ;; esac \ && test $ac_cv_func_mbrtowc = yes; then @@ -408,14 +414,16 @@ AC_DEFUN([gl_MBRTOWC_RETVAL], dnl is present. changequote(,)dnl case "$host_os" in - # Guess no on HP-UX, Solaris, native Windows. - hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_mbrtowc_retval="guessing yes" ;; + # Guess no on HP-UX, Solaris, native Windows. + hpux* | solaris* | mingw* | windows*) + gl_cv_func_mbrtowc_retval="guessing no" ;; + # Guess yes otherwise. + *) + gl_cv_func_mbrtowc_retval="guessing yes" ;; esac changequote([,])dnl if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ - || { case "$host_os" in mingw*) true;; *) false;; esac; }; then + || { case "$host_os" in mingw* | windows*) true;; *) false;; esac; }; then AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include @@ -426,7 +434,8 @@ int main () int result = 0; int found_some_locale = 0; /* This fails on Solaris. */ - if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) { char input[] = "B\303\274\303\237er"; /* "Büßer" */ mbstate_t state; @@ -442,7 +451,8 @@ int main () found_some_locale = 1; } /* This fails on HP-UX 11.11. */ - if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) + if (strcmp ("$LOCALE_JA", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_JA") != NULL) { char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ mbstate_t state; @@ -577,13 +587,13 @@ AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE], dnl is present. changequote(,)dnl case "$host_os" in - # Guess yes on native Windows. - mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;; - *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;; + *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;; esac changequote([,])dnl case "$host_os" in - mingw*) + mingw* | windows*) AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include @@ -677,31 +687,28 @@ AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT], AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether mbrtowc works on empty input], [gl_cv_func_mbrtowc_empty_input], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on AIX and glibc systems. - aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; - *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; - esac -changequote([,])dnl - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ - #include - static wchar_t wc; - static mbstate_t mbs; - int - main (void) - { - return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; - }]])], - [gl_cv_func_mbrtowc_empty_input=yes], - [gl_cv_func_mbrtowc_empty_input=no], - [:]) + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + static wchar_t wc; + static mbstate_t mbs; + int + main (void) + { + return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; + }]])], + [gl_cv_func_mbrtowc_empty_input=yes], + [gl_cv_func_mbrtowc_empty_input=no], + [case "$host_os" in + # Guess no on AIX and glibc systems. + aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; + # Guess no on Android. + linux*-android*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; + *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; + esac + ]) ]) ]) @@ -709,18 +716,17 @@ dnl Test whether mbrtowc reports encoding errors in the C locale. dnl Although POSIX was never intended to allow this, the GNU C Library dnl and other implementations do it. See: dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 +dnl POSIX has now clarified it: +dnl +dnl says: "In the POSIX locale an [EILSEQ] error cannot occur since all byte +dnl values are valid characters." AC_DEFUN([gl_MBRTOWC_C_LOCALE], [ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether the C locale is free of encoding errors], [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. - gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" - - AC_RUN_IFELSE( + [AC_RUN_IFELSE( [AC_LANG_PROGRAM( [[#include #include @@ -741,13 +747,14 @@ AC_DEFUN([gl_MBRTOWC_C_LOCALE], } return 0; ]])], - [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes], - [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no], - [case "$host_os" in - # Guess yes on native Windows. - mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; - esac - ]) + [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes], + [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no], + [case "$host_os" in + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; + *) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;; + esac + ]) ]) ]) diff --git a/gl/m4/mbsinit.m4 b/gl/m4/mbsinit.m4 index c388a8b..10c86ba 100644 --- a/gl/m4/mbsinit.m4 +++ b/gl/m4/mbsinit.m4 @@ -1,5 +1,6 @@ -# mbsinit.m4 serial 9 -dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. +# mbsinit.m4 +# serial 10 +dnl Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -32,7 +33,7 @@ AC_DEFUN([gl_FUNC_MBSINIT], dnl states produced by mbrtowc() for an incomplete multibyte character dnl in multibyte locales. case "$host_os" in - mingw*) REPLACE_MBSINIT=1 ;; + mingw* | windows*) REPLACE_MBSINIT=1 ;; esac fi fi diff --git a/gl/m4/mbstate_t.m4 b/gl/m4/mbstate_t.m4 index dcd66b9..66d65cd 100644 --- a/gl/m4/mbstate_t.m4 +++ b/gl/m4/mbstate_t.m4 @@ -1,5 +1,6 @@ -# mbstate_t.m4 serial 14 -dnl Copyright (C) 2000-2002, 2008-2023 Free Software Foundation, Inc. +# mbstate_t.m4 +# serial 14 +dnl Copyright (C) 2000-2002, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/mbtowc.m4 b/gl/m4/mbtowc.m4 index 7823be0..603b0c1 100644 --- a/gl/m4/mbtowc.m4 +++ b/gl/m4/mbtowc.m4 @@ -1,5 +1,6 @@ -# mbtowc.m4 serial 3 -dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. +# mbtowc.m4 +# serial 5 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -8,9 +9,12 @@ AC_DEFUN([gl_FUNC_MBTOWC], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - AC_CHECK_FUNCS([mbtowc]) + gl_CHECK_FUNCS_ANDROID([mbtowc], [[#include ]]) if test $ac_cv_func_mbtowc = no; then HAVE_MBTOWC=0 + case "$gl_cv_onwards_func_mbtowc" in + future*) REPLACE_MBTOWC=1 ;; + esac else if false; then REPLACE_MBTOWC=1 diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4 index 4f1aed0..346a288 100644 --- a/gl/m4/memchr.m4 +++ b/gl/m4/memchr.m4 @@ -1,5 +1,6 @@ -# memchr.m4 serial 18 -dnl Copyright (C) 2002-2004, 2009-2023 Free Software Foundation, Inc. +# memchr.m4 +# serial 19 +dnl Copyright (C) 2002-2004, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -85,12 +86,12 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], [case "$host_os" in - # Guess no on Android. - linux*-android*) gl_cv_func_memchr_works="guessing no" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_memchr_works="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;; + # Guess no on Android. + linux*-android*) gl_cv_func_memchr_works="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_memchr_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;; esac ]) ]) diff --git a/gl/m4/minmax.m4 b/gl/m4/minmax.m4 index fd09846..bc7d0c3 100644 --- a/gl/m4/minmax.m4 +++ b/gl/m4/minmax.m4 @@ -1,5 +1,6 @@ -# minmax.m4 serial 4 -dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc. +# minmax.m4 +# serial 4 +dnl Copyright (C) 2005, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/mktime.m4 b/gl/m4/mktime.m4 index e9d31f3..85c5245 100644 --- a/gl/m4/mktime.m4 +++ b/gl/m4/mktime.m4 @@ -1,6 +1,6 @@ -# serial 37 -dnl Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation, -dnl Inc. +# mktime.m4 +# serial 39 +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -264,9 +264,9 @@ main () [gl_cv_func_working_mktime=yes], [gl_cv_func_working_mktime=no], [case "$host_os" in - # Guess no on native Windows. - mingw*) gl_cv_func_working_mktime="guessing no" ;; - *) gl_cv_func_working_mktime="$gl_cross_guess_normal" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_working_mktime="guessing no" ;; + *) gl_cv_func_working_mktime="$gl_cross_guess_normal" ;; esac ]) fi @@ -280,7 +280,6 @@ AC_DEFUN([gl_FUNC_MKTIME], AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([gl_FUNC_MKTIME_WORKS]) - REPLACE_MKTIME=0 if test "$gl_cv_func_working_mktime" != yes; then REPLACE_MKTIME=1 AC_DEFINE([NEED_MKTIME_WORKING], [1], @@ -288,7 +287,7 @@ AC_DEFUN([gl_FUNC_MKTIME], with the algorithmic workarounds.]) fi case "$host_os" in - mingw*) + mingw* | windows*) REPLACE_MKTIME=1 AC_DEFINE([NEED_MKTIME_WINDOWS], [1], [Define if the compilation of mktime.c should define 'mktime' diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4 index d07d26e..61ca012 100644 --- a/gl/m4/mmap-anon.m4 +++ b/gl/m4/mmap-anon.m4 @@ -1,5 +1,6 @@ -# mmap-anon.m4 serial 12 -dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc. +# mmap-anon.m4 +# serial 12 +dnl Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/mode_t.m4 b/gl/m4/mode_t.m4 index 82197c0..0d5c280 100644 --- a/gl/m4/mode_t.m4 +++ b/gl/m4/mode_t.m4 @@ -1,5 +1,6 @@ -# mode_t.m4 serial 2 -dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. +# mode_t.m4 +# serial 2 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/mountlist.m4 b/gl/m4/mountlist.m4 index a9b4edb..ff414e6 100644 --- a/gl/m4/mountlist.m4 +++ b/gl/m4/mountlist.m4 @@ -1,5 +1,6 @@ -# serial 15 -dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc. +# mountlist.m4 +# serial 17 +dnl Copyright (C) 2002-2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -106,7 +107,18 @@ $ac_includes_default [Define if there is a function named getmntent for reading the list of mounted file systems, and that function takes a single argument. (4.3BSD, SunOS, HP-UX, Irix)]) - AC_CHECK_FUNCS([setmntent endmntent hasmntopt]) + gl_CHECK_FUNCS_ANDROID([setmntent], + [[#include + #include + ]]) + gl_CHECK_FUNCS_ANDROID([endmntent], + [[#include + #include + ]]) + gl_CHECK_FUNCS_ANDROID([hasmntopt], + [[#include + #include + ]]) fi fi diff --git a/gl/m4/msvc-inval.m4 b/gl/m4/msvc-inval.m4 index 8d9d21b..7919ff1 100644 --- a/gl/m4/msvc-inval.m4 +++ b/gl/m4/msvc-inval.m4 @@ -1,5 +1,6 @@ -# msvc-inval.m4 serial 1 -dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. +# msvc-inval.m4 +# serial 1 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/msvc-nothrow.m4 b/gl/m4/msvc-nothrow.m4 index 0263e49..007c762 100644 --- a/gl/m4/msvc-nothrow.m4 +++ b/gl/m4/msvc-nothrow.m4 @@ -1,5 +1,6 @@ -# msvc-nothrow.m4 serial 1 -dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. +# msvc-nothrow.m4 +# serial 1 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/multiarch.m4 b/gl/m4/multiarch.m4 index 3ba5b0f..3af29d3 100644 --- a/gl/m4/multiarch.m4 +++ b/gl/m4/multiarch.m4 @@ -1,5 +1,6 @@ -# multiarch.m4 serial 9 -dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. +# multiarch.m4 +# serial 9 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/musl.m4 b/gl/m4/musl.m4 new file mode 100644 index 0000000..0d4de89 --- /dev/null +++ b/gl/m4/musl.m4 @@ -0,0 +1,21 @@ +# musl.m4 +# serial 4 +dnl Copyright (C) 2019-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Test for musl libc, despite the musl libc authors don't like it +# +# . +# From Bruno Haible. + +AC_DEFUN_ONCE([gl_MUSL_LIBC], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + *-musl* | midipix*) + AC_DEFINE([MUSL_LIBC], [1], [Define to 1 on musl libc.]) + ;; + esac +]) diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4 index e6aa892..d8c0021 100644 --- a/gl/m4/netdb_h.m4 +++ b/gl/m4/netdb_h.m4 @@ -1,5 +1,6 @@ -# netdb_h.m4 serial 15 -dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. +# netdb_h.m4 +# serial 15 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4 index 7115419..926f7f9 100644 --- a/gl/m4/netinet_in_h.m4 +++ b/gl/m4/netinet_in_h.m4 @@ -1,5 +1,6 @@ -# netinet_in_h.m4 serial 6 -dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. +# netinet_in_h.m4 +# serial 6 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/nl_langinfo.m4 b/gl/m4/nl_langinfo.m4 index 51e783c..f38f11b 100644 --- a/gl/m4/nl_langinfo.m4 +++ b/gl/m4/nl_langinfo.m4 @@ -1,5 +1,6 @@ -# nl_langinfo.m4 serial 8 -dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. +# nl_langinfo.m4 +# serial 11 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -8,7 +9,7 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO], [ AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) AC_REQUIRE([gl_LANGINFO_H]) - AC_CHECK_FUNCS_ONCE([nl_langinfo]) + gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include ]]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) AC_REQUIRE([gl_PTHREADLIB]) @@ -60,9 +61,12 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO], fi else HAVE_NL_LANGINFO=0 + case "$gl_cv_onwards_func_nl_langinfo" in + future*) REPLACE_NL_LANGINFO=1 ;; + esac fi if test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0; then - LIB_NL_LANGINFO="$LIB_SETLOCALE_NULL" + LIB_NL_LANGINFO="$SETLOCALE_NULL_LIB" else LIB_NL_LANGINFO= fi diff --git a/gl/m4/nocrash.m4 b/gl/m4/nocrash.m4 index 6a76638..cbe8fe8 100644 --- a/gl/m4/nocrash.m4 +++ b/gl/m4/nocrash.m4 @@ -1,5 +1,6 @@ -# nocrash.m4 serial 5 -dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc. +# nocrash.m4 +# serial 5 +dnl Copyright (C) 2005, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/off_t.m4 b/gl/m4/off_t.m4 index 880f347..db6035d 100644 --- a/gl/m4/off_t.m4 +++ b/gl/m4/off_t.m4 @@ -1,5 +1,6 @@ -# off_t.m4 serial 1 -dnl Copyright (C) 2012-2023 Free Software Foundation, Inc. +# off_t.m4 +# serial 1 +dnl Copyright (C) 2012-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/open-cloexec.m4 b/gl/m4/open-cloexec.m4 index fd572fc..6defdfb 100644 --- a/gl/m4/open-cloexec.m4 +++ b/gl/m4/open-cloexec.m4 @@ -1,10 +1,12 @@ -# Test whether O_CLOEXEC is defined. - -dnl Copyright 2017-2023 Free Software Foundation, Inc. +# open-cloexec.m4 +# serial 1 +dnl Copyright 2017-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +# Test whether O_CLOEXEC is defined. + AC_DEFUN([gl_PREPROC_O_CLOEXEC], [ AC_CACHE_CHECK([for O_CLOEXEC], diff --git a/gl/m4/open-slash.m4 b/gl/m4/open-slash.m4 index 1f731f8..03460e4 100644 --- a/gl/m4/open-slash.m4 +++ b/gl/m4/open-slash.m4 @@ -1,5 +1,6 @@ -# open-slash.m4 serial 2 -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# open-slash.m4 +# serial 2 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/open.m4 b/gl/m4/open.m4 index 94fa2bb..62a11a1 100644 --- a/gl/m4/open.m4 +++ b/gl/m4/open.m4 @@ -1,5 +1,6 @@ -# open.m4 serial 15 -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# open.m4 +# serial 16 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -9,7 +10,7 @@ AC_DEFUN([gl_FUNC_OPEN], AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([gl_PREPROC_O_CLOEXEC]) case "$host_os" in - mingw* | pw*) + mingw* | windows* | pw*) REPLACE_OPEN=1 ;; *) diff --git a/gl/m4/pathmax.m4 b/gl/m4/pathmax.m4 index 6d47d2c..4280837 100644 --- a/gl/m4/pathmax.m4 +++ b/gl/m4/pathmax.m4 @@ -1,5 +1,6 @@ -# pathmax.m4 serial 11 -dnl Copyright (C) 2002-2003, 2005-2006, 2009-2023 Free Software Foundation, +# pathmax.m4 +# serial 11 +dnl Copyright (C) 2002-2003, 2005-2006, 2009-2024 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/pid_t.m4 b/gl/m4/pid_t.m4 index 0fd7d0a..8bedcc6 100644 --- a/gl/m4/pid_t.m4 +++ b/gl/m4/pid_t.m4 @@ -1,5 +1,6 @@ -# pid_t.m4 serial 4 -dnl Copyright (C) 2020-2023 Free Software Foundation, Inc. +# pid_t.m4 +# serial 4 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4 index 4e65abc..0cb14d6 100644 --- a/gl/m4/printf.m4 +++ b/gl/m4/printf.m4 @@ -1,5 +1,6 @@ -# printf.m4 serial 73 -dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc. +# printf.m4 +# serial 91 +dnl Copyright (C) 2003, 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -63,7 +64,7 @@ changequote(,)dnl # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; # Guess yes on musl systems. - *-musl*) gl_cv_func_printf_sizes_c99="guessing yes";; + *-musl* | midipix*) gl_cv_func_printf_sizes_c99="guessing yes";; # Guess yes on FreeBSD >= 5. freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";; freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; @@ -86,7 +87,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_printf_sizes_c99="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -101,6 +103,92 @@ changequote([,])dnl ]) ]) +dnl Test whether the *printf family of functions supports the 'w8', 'w16', +dnl 'w32', 'w64', 'wf8', 'wf16', 'wf32', 'wf64' size specifiers. (ISO C23) +dnl Result is gl_cv_func_printf_sizes_c23. + +AC_DEFUN([gl_PRINTF_SIZES_C23], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports size specifiers as in C23], + [gl_cv_func_printf_sizes_c23], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#if HAVE_STDINT_H_WITH_UINTMAX +# include +#endif +#if HAVE_INTTYPES_H_WITH_UINTMAX +# include +#endif +static char buf[100]; +int main () +{ + int result = 0; + buf[0] = '\0'; + if (sprintf (buf, "%w8u %d", (uint8_t) 123, 33, 44, 55) < 0 + || strcmp (buf, "123 33") != 0) + result |= 1; + buf[0] = '\0'; + if (sprintf (buf, "%wf8u %d", (uint_fast8_t) 123, 33, 44, 55) < 0 + || strcmp (buf, "123 33") != 0) + result |= 1; + buf[0] = '\0'; + if (sprintf (buf, "%w16u %d", (uint16_t) 12345, 33, 44, 55) < 0 + || strcmp (buf, "12345 33") != 0) + result |= 2; + buf[0] = '\0'; + if (sprintf (buf, "%wf16u %d", (uint_fast16_t) 12345, 33, 44, 55) < 0 + || strcmp (buf, "12345 33") != 0) + result |= 2; + buf[0] = '\0'; + if (sprintf (buf, "%w32u %d", (uint32_t) 12345671, 33, 44, 55) < 0 + || strcmp (buf, "12345671 33") != 0) + result |= 4; + buf[0] = '\0'; + if (sprintf (buf, "%wf32u %d", (uint_fast32_t) 12345671, 33, 44, 55) < 0 + || strcmp (buf, "12345671 33") != 0) + result |= 4; +#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX + buf[0] = '\0'; + if (sprintf (buf, "%w64u %d", (uint64_t) 12345671, 33, 44, 55) < 0 + || strcmp (buf, "12345671 33") != 0) + result |= 8; + buf[0] = '\0'; + if (sprintf (buf, "%wf64u %d", (uint_fast64_t) 12345671, 33, 44, 55) < 0 + || strcmp (buf, "12345671 33") != 0) + result |= 8; +#else + result |= 8; +#endif + return result; +}]])], + [gl_cv_func_printf_sizes_c23=yes], + [gl_cv_func_printf_sizes_c23=no], + [ + case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_printf_sizes_c23="guessing no";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_printf_sizes_c23="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_sizes_c23="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_sizes_c23="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_sizes_c23="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + dnl Test whether the *printf family of functions supports 'long double' dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001) dnl Result is gl_cv_func_printf_long_double. @@ -137,20 +225,21 @@ int main () [gl_cv_func_printf_long_double=yes], [gl_cv_func_printf_long_double=no], [case "$host_os" in - # Guess no on BeOS. - beos*) gl_cv_func_printf_long_double="guessing no";; - # Guess yes on Android. - linux*-android*) gl_cv_func_printf_long_double="guessing yes";; - # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + # Guess no on BeOS. + beos*) gl_cv_func_printf_long_double="guessing no";; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_long_double="guessing yes";; + # Guess yes on MSVC, no on mingw. + windows*-msvc*) gl_cv_func_printf_long_double="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif - ], - [gl_cv_func_printf_long_double="guessing yes"], - [gl_cv_func_printf_long_double="guessing no"]) - ;; - *) gl_cv_func_printf_long_double="guessing yes";; + ], + [gl_cv_func_printf_long_double="guessing yes"], + [gl_cv_func_printf_long_double="guessing no"]) + ;; + *) gl_cv_func_printf_long_double="guessing yes";; esac ]) ]) @@ -244,7 +333,7 @@ changequote(,)dnl # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";; # Guess yes on musl systems. - *-musl*) gl_cv_func_printf_infinite="guessing yes";; + *-musl* | midipix*) gl_cv_func_printf_infinite="guessing yes";; # Guess yes on FreeBSD >= 6. freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";; freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; @@ -268,7 +357,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_printf_infinite="guessing no";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_printf_infinite="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -467,7 +557,7 @@ changequote(,)dnl # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; # Guess yes on musl systems. - *-musl*) gl_cv_func_printf_infinite_long_double="guessing yes";; + *-musl* | midipix*) gl_cv_func_printf_infinite_long_double="guessing yes";; # Guess yes on FreeBSD >= 6. freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";; freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; @@ -482,7 +572,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_printf_infinite_long_double="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -591,11 +682,11 @@ int main () [gl_cv_func_printf_directive_a="guessing no"]) ;; # Guess yes on musl systems. - *-musl*) gl_cv_func_printf_directive_a="guessing yes";; + *-musl* | midipix*) gl_cv_func_printf_directive_a="guessing yes";; # Guess no on Android. linux*-android*) gl_cv_func_printf_directive_a="guessing no";; # Guess no on native Windows. - mingw*) gl_cv_func_printf_directive_a="guessing no";; + mingw* | windows*) gl_cv_func_printf_directive_a="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";; esac @@ -603,6 +694,116 @@ int main () ]) ]) +dnl Test whether the *printf family of functions supports the 'b' conversion +dnl specifier for binary output of integers. +dnl (ISO C23) +dnl Result is gl_cv_func_printf_directive_b. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_B], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'b' directive], + [gl_cv_func_printf_directive_b], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[100]; +int main () +{ + int result = 0; + if (sprintf (buf, "%b %d", 12345, 33, 44, 55) < 0 + || strcmp (buf, "11000000111001 33") != 0) + result |= 1; + return result; +}]])], + [gl_cv_func_printf_directive_b=yes], + [gl_cv_func_printf_directive_b=no], + [ + case "$host_os" in + # Guess yes on glibc >= 2.35 systems. + *-gnu* | gnu*) + AC_EGREP_CPP([Lucky], [ + #include + #ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 35) || (__GLIBC__ > 2) + Lucky user + #endif + #endif + ], + [gl_cv_func_printf_directive_uppercase_b="guessing yes"], + [gl_cv_func_printf_directive_uppercase_b="guessing no"]) + ;; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_printf_directive_b="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_b="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_b="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_directive_b="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the 'B' conversion +dnl specifier for binary output of integers. +dnl (GNU, encouraged by ISO C23 § 7.23.6.1) +dnl Result is gl_cv_func_printf_directive_uppercase_b. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_UPPERCASE_B], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'B' directive], + [gl_cv_func_printf_directive_uppercase_b], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[100]; +int main () +{ + int result = 0; + if (sprintf (buf, "%#B %d", 12345, 33, 44, 55) < 0 + || strcmp (buf, "0B11000000111001 33") != 0) + result |= 1; + return result; +}]])], + [gl_cv_func_printf_directive_uppercase_b=yes], + [gl_cv_func_printf_directive_uppercase_b=no], + [ + case "$host_os" in + # Guess yes on glibc >= 2.35 systems. + *-gnu* | gnu*) + AC_EGREP_CPP([Lucky], [ + #include + #ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 35) || (__GLIBC__ > 2) + Lucky user + #endif + #endif + ], + [gl_cv_func_printf_directive_uppercase_b="guessing yes"], + [gl_cv_func_printf_directive_uppercase_b="guessing no"]) + ;; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_printf_directive_uppercase_b="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_uppercase_b="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_uppercase_b="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_directive_uppercase_b="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + dnl Test whether the *printf family of functions supports the %F format dnl directive. (ISO C99, POSIX:2001) dnl Result is gl_cv_func_printf_directive_f. @@ -643,7 +844,7 @@ changequote(,)dnl # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";; # Guess yes on musl systems. - *-musl*) gl_cv_func_printf_directive_f="guessing yes";; + *-musl* | midipix*) gl_cv_func_printf_directive_f="guessing yes";; # Guess yes on FreeBSD >= 6. freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";; freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; @@ -661,7 +862,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_printf_directive_f="guessing no";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_printf_directive_f="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -689,6 +891,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N], [ AC_RUN_IFELSE( [AC_LANG_SOURCE([[ +#include #include #include #include @@ -706,6 +909,12 @@ invalid_parameter_handler (const wchar_t *expression, exit (1); } #endif +static void +abort_handler (int sig) +{ + (void) sig; + _exit (1); +} static char fmtstring[10]; static char buf[100]; int main () @@ -714,6 +923,7 @@ int main () #ifdef _MSC_VER _set_invalid_parameter_handler (invalid_parameter_handler); #endif + signal (SIGABRT, abort_handler); /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) support %n in format strings in read-only memory but not in writable memory. */ @@ -727,21 +937,21 @@ int main () [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no], [case "$host_os" in - # Guess no on glibc when _FORTIFY_SOURCE >= 2. - *-gnu* | gnu*) AC_COMPILE_IFELSE( - [AC_LANG_SOURCE( - [[#if _FORTIFY_SOURCE >= 2 - error fail - #endif - ]])], - [gl_cv_func_printf_directive_n="guessing yes"], - [gl_cv_func_printf_directive_n="guessing no"]) - ;; - # Guess no on Android. - linux*-android*) gl_cv_func_printf_directive_n="guessing no";; - # Guess no on native Windows. - mingw*) gl_cv_func_printf_directive_n="guessing no";; - *) gl_cv_func_printf_directive_n="guessing yes";; + # Guess no on glibc when _FORTIFY_SOURCE >= 2. + *-gnu* | gnu*) AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if _FORTIFY_SOURCE >= 2 + error fail + #endif + ]])], + [gl_cv_func_printf_directive_n="guessing yes"], + [gl_cv_func_printf_directive_n="guessing no"]) + ;; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_n="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_n="guessing no";; + *) gl_cv_func_printf_directive_n="guessing yes";; esac ]) ]) @@ -811,18 +1021,64 @@ int main () [ changequote(,)dnl case "$host_os" in - # Guess yes on OpenBSD >= 6.0. - openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";; - openbsd*) gl_cv_func_printf_directive_ls="guessing yes";; - irix*) gl_cv_func_printf_directive_ls="guessing no";; - solaris*) gl_cv_func_printf_directive_ls="guessing no";; - cygwin*) gl_cv_func_printf_directive_ls="guessing no";; - beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; - # Guess no on Android. - linux*-android*) gl_cv_func_printf_directive_ls="guessing no";; - # Guess yes on native Windows. - mingw*) gl_cv_func_printf_directive_ls="guessing yes";; - *) gl_cv_func_printf_directive_ls="guessing yes";; + # Guess yes on OpenBSD >= 6.0. + openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";; + openbsd*) gl_cv_func_printf_directive_ls="guessing yes";; + irix*) gl_cv_func_printf_directive_ls="guessing no";; + solaris*) gl_cv_func_printf_directive_ls="guessing no";; + cygwin*) gl_cv_func_printf_directive_ls="guessing no";; + beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_ls="guessing no";; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_ls="guessing yes";; + *) gl_cv_func_printf_directive_ls="guessing yes";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the %lc format +dnl directive and in particular, when the argument is a null wide character, +dnl whether the functions produce a NUL byte, as specified in ISO C 23 +dnl after the issue GB-141 was fixed. +dnl Result is gl_cv_func_printf_directive_lc. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_LC], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'lc' directive correctly], + [gl_cv_func_printf_directive_lc], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + int result = 0; + char buf[100]; + /* This test fails on musl libc 1.2.4. */ + { + buf[0] = '\0'; + if (sprintf (buf, "%lc%lc%lc", (wint_t) 'a', (wint_t) 0, (wint_t) 'z') < 0 + || memcmp (buf, "a\0z", 4) != 0) + result |= 1; + } + return result; +}]])], + [gl_cv_func_printf_directive_lc=yes], + [gl_cv_func_printf_directive_lc=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no on musl libc. + *-musl* | midipix*) gl_cv_func_printf_directive_lc="guessing no";; + # Guess yes otherwise. + *) gl_cv_func_printf_directive_lc="guessing yes";; esac changequote([,])dnl ]) @@ -833,7 +1089,7 @@ dnl Test whether the *printf family of functions supports POSIX/XSI format dnl strings with positions. (POSIX:2001) dnl Result is gl_cv_func_printf_positions. -AC_DEFUN([gl_PRINTF_POSITIONS], +AC_DEFUN_ONCE([gl_PRINTF_POSITIONS], [ AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles @@ -859,13 +1115,17 @@ int main () changequote(,)dnl case "$host_os" in netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) - gl_cv_func_printf_positions="guessing no";; - beos*) gl_cv_func_printf_positions="guessing no";; - # Guess yes on Android. - linux*-android*) gl_cv_func_printf_positions="guessing yes";; - # Guess no on native Windows. - mingw* | pw*) gl_cv_func_printf_positions="guessing no";; - *) gl_cv_func_printf_positions="guessing yes";; + gl_cv_func_printf_positions="guessing no";; + beos*) + gl_cv_func_printf_positions="guessing no";; + # Guess yes on Android. + linux*-android*) + gl_cv_func_printf_positions="guessing yes";; + # Guess no on native Windows. + mingw* | windows* | pw*) + gl_cv_func_printf_positions="guessing no";; + *) + gl_cv_func_printf_positions="guessing yes";; esac changequote([,])dnl ]) @@ -900,13 +1160,13 @@ int main () [ changequote(,)dnl case "$host_os" in - cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; - netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; - # Guess no on Android. - linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";; - # Guess no on native Windows. - mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; - *) gl_cv_func_printf_flag_grouping="guessing yes";; + cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; + netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";; + # Guess no on native Windows. + mingw* | windows* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; + *) gl_cv_func_printf_flag_grouping="guessing yes";; esac changequote([,])dnl ]) @@ -943,16 +1203,16 @@ int main () [ changequote(,)dnl case "$host_os" in - # Guess yes on HP-UX 11. - hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; - # Guess no on HP-UX 10 and older. - hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; - # Guess yes on Android. - linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";; - # Guess yes on native Windows. - mingw*) gl_cv_func_printf_flag_leftadjust="guessing yes";; - # Guess yes otherwise. - *) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess yes on HP-UX 11. + hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess no on HP-UX 10 and older. + hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess yes otherwise. + *) gl_cv_func_printf_flag_leftadjust="guessing yes";; esac changequote([,])dnl ]) @@ -990,18 +1250,62 @@ int main () [ changequote(,)dnl case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";; - # Guess yes on musl systems. - *-musl*) gl_cv_func_printf_flag_zero="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_printf_flag_zero="guessing yes";; - # Guess no on Android. - linux*-android*) gl_cv_func_printf_flag_zero="guessing no";; - # Guess no on native Windows. - mingw*) gl_cv_func_printf_flag_zero="guessing no";; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_printf_flag_zero="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_printf_flag_zero="guessing yes";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_flag_zero="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_flag_zero="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the # flag with a +dnl zero precision and a zero value in the 'x' and 'X' directives correctly. +dnl ISO C and POSIX specify that for the 'd', 'i', 'b', 'o', 'u', 'x', 'X' +dnl directives: "The result of converting a zero value with a precision of +dnl zero is no characters." But on Mac OS X 10.5, for the 'x', 'X' directives, +dnl when a # flag is present, the output is "0" instead of "". +dnl Result is gl_cv_func_printf_flag_alt_precision_zero. + +AC_DEFUN([gl_PRINTF_FLAG_ALT_PRECISION_ZERO], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the alternative flag with a zero precision], + [gl_cv_func_printf_flag_alt_precision_zero], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +static char buf[10]; +int main () +{ + int result = 0; + if (sprintf (buf, "%#.0x %d", 0, 33, 44) > 0 + 3) + result |= 1; + return result; +}]])], + [gl_cv_func_printf_flag_alt_precision_zero=yes], + [gl_cv_func_printf_flag_alt_precision_zero=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no only on macOS 10..12 systems. + darwin[0-9] | darwin[0-9].* | \ + darwin1[0-9] | darwin1[0-9].* | \ + darwin2[0-1] | darwin2[0-1].*) + gl_cv_func_printf_flag_alt_precision_zero="guessing no" ;; + darwin*) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;; + *) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;; esac changequote([,])dnl ]) @@ -1054,12 +1358,12 @@ int main () changequote(,)dnl case "$host_os" in # Guess no only on Solaris, native Windows, and BeOS systems. - solaris*) gl_cv_func_printf_precision="guessing no" ;; - mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; - beos*) gl_cv_func_printf_precision="guessing no" ;; - # Guess yes on Android. - linux*-android*) gl_cv_func_printf_precision="guessing yes" ;; - *) gl_cv_func_printf_precision="guessing yes" ;; + solaris*) gl_cv_func_printf_precision="guessing no" ;; + mingw* | windows* | pw*) gl_cv_func_printf_precision="guessing no" ;; + beos*) gl_cv_func_printf_precision="guessing no" ;; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_precision="guessing yes" ;; + *) gl_cv_func_printf_precision="guessing yes" ;; esac changequote([,])dnl ]) @@ -1239,7 +1543,7 @@ changequote(,)dnl # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on musl systems. - *-musl*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + *-musl* | midipix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on FreeBSD >= 5. freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";; freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; @@ -1275,7 +1579,7 @@ changequote(,)dnl # Guess yes on Android. linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess no on native Windows. - mingw*) gl_cv_func_snprintf_truncation_c99="guessing no";; + mingw* | windows*) gl_cv_func_snprintf_truncation_c99="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";; esac @@ -1344,7 +1648,7 @@ changequote(,)dnl # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; # Guess yes on musl systems. - *-musl*) gl_cv_func_snprintf_retval_c99="guessing yes";; + *-musl* | midipix*) gl_cv_func_snprintf_retval_c99="guessing yes";; # Guess yes on FreeBSD >= 5. freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";; freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; @@ -1372,7 +1676,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_snprintf_retval_c99="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -1401,6 +1706,7 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], [ AC_RUN_IFELSE( [AC_LANG_SOURCE([[ +#include #include #include #if HAVE_SNPRINTF @@ -1417,11 +1723,18 @@ static int my_snprintf (char *buf, int size, const char *format, ...) return ret; } #endif +static void +abort_handler (int sig) +{ + (void) sig; + _exit (1); +} static char fmtstring[10]; static char buf[100]; int main () { int count = -1; + signal (SIGABRT, abort_handler); /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) support %n in format strings in read-only memory but not in writable memory. */ @@ -1447,7 +1760,7 @@ int main () ;; changequote(,)dnl # Guess yes on musl systems. - *-musl*) gl_cv_func_snprintf_directive_n="guessing yes";; + *-musl* | midipix*) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on FreeBSD >= 5. freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";; freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; @@ -1476,7 +1789,7 @@ changequote(,)dnl # Guess no on Android. linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";; # Guess no on native Windows. - mingw*) gl_cv_func_snprintf_directive_n="guessing no";; + mingw* | windows*) gl_cv_func_snprintf_directive_n="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";; changequote([,])dnl @@ -1524,11 +1837,11 @@ int main() [gl_cv_func_snprintf_size1=yes], [gl_cv_func_snprintf_size1=no], [case "$host_os" in - # Guess yes on Android. - linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_snprintf_size1="guessing yes" ;; - *) gl_cv_func_snprintf_size1="guessing yes" ;; + # Guess yes on Android. + linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_snprintf_size1="guessing yes" ;; + *) gl_cv_func_snprintf_size1="guessing yes" ;; esac ]) ]) @@ -1601,128 +1914,320 @@ int main() [ changequote(,)dnl case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on musl systems. - *-musl*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Mac OS X >= 10.3. - darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Cygwin. - cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Mac OS X >= 10.3. + darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Cygwin. + cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. solaris2.[0-5] | solaris2.[0-5].*) - gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on NetBSD >= 3. + gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on NetBSD >= 3. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Android. - linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on native Windows. - mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";; + gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Android. + linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on native Windows. + mingw* | windows* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";; esac changequote([,])dnl ]) ]) ]) +dnl Test whether the swprintf function works correctly when it produces output +dnl that contains null wide characters. +dnl Result is gl_cv_func_swprintf_works. + +AC_DEFUN([gl_SWPRINTF_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([swprintf]) + AC_CACHE_CHECK([whether swprintf works], + [gl_cv_func_swprintf_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#ifndef __USE_MINGW_ANSI_STDIO +# define __USE_MINGW_ANSI_STDIO 1 +#endif +#include +#include +int main() +{ + int result = 0; + { /* This test fails on musl libc 1.2.3, FreeBSD, NetBSD, OpenBSD, macOS, AIX. */ + wchar_t buf[5] = { 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF }; + int ret = swprintf (buf, 4, L"%cz", '\0'); + /* Expected result: + ret = 2, buf[0] = 0x0, buf[1] = 0x7a, buf[2] = 0x0, buf[3] = 0xbeef + musl libc 1.2.3: + ret = 2, buf[0] = 0x0, buf[1] = 0x0, buf[2] = 0x0, buf[3] = 0x0 + Reported at . + FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2: + ret = 2, buf[0] = 0x0, buf[1] = 0xbeef, buf[2] = 0xbeef, buf[3] = 0xbeef + */ + if (ret < 0 || buf[1] != 'z') + result |= 1; + } + { /* This test fails on mingw. */ + wchar_t buf[2]; + int ret = swprintf (buf, 2, L"%lc", (wint_t)0); + /* Expected: ret = 1 + mingw: ret = 0 + */ + if (ret != 1) + result |= 2; + } + return result; +}]])], + [gl_cv_func_swprintf_works=yes], + [gl_cv_func_swprintf_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_swprintf_works="guessing yes";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_works="guessing no";; + # Guess no on FreeBSD, NetBSD, OpenBSD, macOS, AIX. + freebsd* | midnightbsd* | netbsd* | openbsd* | darwin* | aix*) + gl_cv_func_swprintf_works="guessing no";; + # Guess no on native Windows. + mingw* | windows* | pw*) gl_cv_func_swprintf_works="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_works="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *wprintf family of functions supports the 'a' and 'A' +dnl conversion specifier for hexadecimal output of 'long double' numbers. +dnl (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_swprintf_directive_la. + +AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LA], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether swprintf supports the 'La' and 'LA' directives], + [gl_cv_func_swprintf_directive_la], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static wchar_t buf[100]; +int main () +{ + int result = 0; + /* This catches a glibc 2.15, Haiku 2022, NetBSD 10.0 bug. */ + if (swprintf (buf, sizeof (buf) / sizeof (wchar_t), + L"%La %d", 3.1416015625L, 33, 44, 55) < 0 + || (wcscmp (buf, L"0x1.922p+1 33") != 0 + && wcscmp (buf, L"0x3.244p+0 33") != 0 + && wcscmp (buf, L"0x6.488p-1 33") != 0 + && wcscmp (buf, L"0xc.91p-2 33") != 0)) + result |= 1; + return result; +}]])], + [gl_cv_func_swprintf_directive_la=yes], + [gl_cv_func_swprintf_directive_la=no], + [case "$host_os" in + # Guess yes on glibc >= 2.17 systems. + *-gnu* | gnu*) + AC_EGREP_CPP([Unlucky], [ + #include + #ifdef __GNU_LIBRARY__ + #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16) || (__GLIBC__ > 2)) && !defined __UCLIBC__ + Unlucky + #endif + #endif + ], + [gl_cv_func_swprintf_directive_la="guessing yes"], + [gl_cv_func_swprintf_directive_la="guessing no"]) + ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_directive_la="guessing yes";; + # Guess yes on Android. + linux*-android*) gl_cv_func_swprintf_directive_la="guessing yes";; + # Guess no on NetBSD. + netbsd*) gl_cv_func_swprintf_directive_la="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_swprintf_directive_la="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_directive_la="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *wprintf family of functions supports the 'lc' conversion +dnl specifier for all wide characters. +dnl (ISO C11, POSIX:2001) +dnl Result is gl_cv_func_swprintf_directive_lc. + +AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LC], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether swprintf supports the 'lc' directive], + [gl_cv_func_swprintf_directive_lc], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static wchar_t buf[100]; +static wint_t L_invalid = (wchar_t) 0x76543210; +int main () +{ + int result = 0; + /* This catches a musl libc 1.2.4, Android bug. + Reported at . */ + if (swprintf (buf, sizeof (buf) / sizeof (wchar_t), + L"%lc %d", L_invalid, 33, 44, 55) < 0) + result |= 1; + return result; +}]])], + [gl_cv_func_swprintf_directive_lc=yes], + [gl_cv_func_swprintf_directive_lc=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_swprintf_directive_lc="guessing yes";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_directive_lc="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_swprintf_directive_lc="guessing no";; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_swprintf_directive_lc="guessing yes";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_directive_lc="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + dnl The results of these tests on various platforms are: dnl dnl 1 = gl_PRINTF_SIZES_C99 -dnl 2 = gl_PRINTF_LONG_DOUBLE -dnl 3 = gl_PRINTF_INFINITE -dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE -dnl 5 = gl_PRINTF_DIRECTIVE_A -dnl 6 = gl_PRINTF_DIRECTIVE_F -dnl 7 = gl_PRINTF_DIRECTIVE_N -dnl 8 = gl_PRINTF_DIRECTIVE_LS -dnl 9 = gl_PRINTF_POSITIONS -dnl 10 = gl_PRINTF_FLAG_GROUPING -dnl 11 = gl_PRINTF_FLAG_LEFTADJUST -dnl 12 = gl_PRINTF_FLAG_ZERO -dnl 13 = gl_PRINTF_PRECISION -dnl 14 = gl_PRINTF_ENOMEM -dnl 15 = gl_SNPRINTF_PRESENCE -dnl 16 = gl_SNPRINTF_TRUNCATION_C99 -dnl 17 = gl_SNPRINTF_RETVAL_C99 -dnl 18 = gl_SNPRINTF_DIRECTIVE_N -dnl 19 = gl_SNPRINTF_SIZE1 -dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99 +dnl 2 = gl_PRINTF_SIZES_C23 +dnl 3 = gl_PRINTF_LONG_DOUBLE +dnl 4 = gl_PRINTF_INFINITE +dnl 5 = gl_PRINTF_INFINITE_LONG_DOUBLE +dnl 6 = gl_PRINTF_DIRECTIVE_A +dnl 7 = gl_PRINTF_DIRECTIVE_B +dnl 8 = gl_PRINTF_DIRECTIVE_UPPERCASE_B +dnl 9 = gl_PRINTF_DIRECTIVE_F +dnl 10 = gl_PRINTF_DIRECTIVE_N +dnl 11 = gl_PRINTF_DIRECTIVE_LS +dnl 12 = gl_PRINTF_DIRECTIVE_LC +dnl 13 = gl_PRINTF_POSITIONS +dnl 14 = gl_PRINTF_FLAG_GROUPING +dnl 15 = gl_PRINTF_FLAG_LEFTADJUST +dnl 16 = gl_PRINTF_FLAG_ZERO +dnl 17 = gl_PRINTF_FLAG_ALT_PRECISION_ZERO +dnl 18 = gl_PRINTF_PRECISION +dnl 19 = gl_PRINTF_ENOMEM +dnl 20 = gl_SNPRINTF_PRESENCE +dnl 21 = gl_SNPRINTF_TRUNCATION_C99 +dnl 22 = gl_SNPRINTF_RETVAL_C99 +dnl 23 = gl_SNPRINTF_DIRECTIVE_N +dnl 24 = gl_SNPRINTF_SIZE1 +dnl 25 = gl_VSNPRINTF_ZEROSIZE_C99 +dnl 26 = gl_SWPRINTF_WORKS +dnl 27 = gl_SWPRINTF_DIRECTIVE_LA +dnl 28 = gl_SWPRINTF_DIRECTIVE_LC dnl dnl 1 = checking whether printf supports size specifiers as in C99... -dnl 2 = checking whether printf supports 'long double' arguments... -dnl 3 = checking whether printf supports infinite 'double' arguments... -dnl 4 = checking whether printf supports infinite 'long double' arguments... -dnl 5 = checking whether printf supports the 'a' and 'A' directives... -dnl 6 = checking whether printf supports the 'F' directive... -dnl 7 = checking whether printf supports the 'n' directive... -dnl 8 = checking whether printf supports the 'ls' directive... -dnl 9 = checking whether printf supports POSIX/XSI format strings with positions... -dnl 10 = checking whether printf supports the grouping flag... -dnl 11 = checking whether printf supports the left-adjust flag correctly... -dnl 12 = checking whether printf supports the zero flag correctly... -dnl 13 = checking whether printf supports large precisions... -dnl 14 = checking whether printf survives out-of-memory conditions... -dnl 15 = checking for snprintf... -dnl 16 = checking whether snprintf truncates the result as in C99... -dnl 17 = checking whether snprintf returns a byte count as in C99... -dnl 18 = checking whether snprintf fully supports the 'n' directive... -dnl 19 = checking whether snprintf respects a size of 1... -dnl 20 = checking whether vsnprintf respects a zero size as in C99... +dnl 2 = checking whether printf supports size specifiers as in C23... +dnl 3 = checking whether printf supports 'long double' arguments... +dnl 4 = checking whether printf supports infinite 'double' arguments... +dnl 5 = checking whether printf supports infinite 'long double' arguments... +dnl 6 = checking whether printf supports the 'a' and 'A' directives... +dnl 7 = checking whether printf supports the 'b' directive... +dnl 8 = checking whether printf supports the 'B' directive... +dnl 9 = checking whether printf supports the 'F' directive... +dnl 10 = checking whether printf supports the 'n' directive... +dnl 11 = checking whether printf supports the 'ls' directive... +dnl 12 = checking whether printf supports the 'lc' directive correctly... +dnl 13 = checking whether printf supports POSIX/XSI format strings with positions... +dnl 14 = checking whether printf supports the grouping flag... +dnl 15 = checking whether printf supports the left-adjust flag correctly... +dnl 16 = checking whether printf supports the zero flag correctly... +dnl 17 = checking whether printf supports the alternative flag with a zero precision... +dnl 18 = checking whether printf supports large precisions... +dnl 19 = checking whether printf survives out-of-memory conditions... +dnl 20 = checking for snprintf... +dnl 21 = checking whether snprintf truncates the result as in C99... +dnl 22 = checking whether snprintf returns a byte count as in C99... +dnl 23 = checking whether snprintf fully supports the 'n' directive... +dnl 24 = checking whether snprintf respects a size of 1... +dnl 25 = checking whether vsnprintf respects a zero size as in C99... +dnl 26 = checking whether swprintf works... +dnl 27 = checking whether swprintf supports the 'La' and 'LA' directives... +dnl 28 = checking whether swprintf supports the 'lc' directive... dnl dnl . = yes, # = no. dnl -dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . -dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . -dnl FreeBSD 13.0 . . . . # . . . . . . . . # . . . . . . -dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . -dnl Mac OS X 10.13.5 . . . # # . # . . . . . . . . . . # . . -dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . . -dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . . -dnl OpenBSD 6.0, 6.7 . . . . # . . . . . . . . # . . . . . . -dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . -dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . -dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . -dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . -dnl Solaris 11.4 . . # # # . . # . . . # . . . . . . . . -dnl Solaris 11.3 . . . . # . . # . . . . . . . . . . . . -dnl Solaris 11.0 . . # # # . . # . . . # . . . . . . . . -dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . -dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . . -dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # -dnl AIX 7.1 . . # # # . . . . . . # # . . . . . . . -dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . . -dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . # . . . -dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . . -dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . # -dnl HP-UX 10.20 # . # . # # . ? . . # # . . . . # # ? # -dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . -dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # -dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # -dnl NetBSD 9.0 . . . . # . . . . . . . . . . . . . . . -dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . -dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? -dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . -dnl Haiku . . . # # # . # . . . . . ? . . ? . . . -dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . . -dnl Android 4.3 . . # # # # # # . # . # . # . . . # . . -dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . . -dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . . -dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . . -dnl mingw-w64 2011 # # # # # # . . # # . # # ? . # # # . . +dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 +dnl musl libc 1.2.3 . # . . . . # # . . . # . . . . ? . . . . . . . . # . # +dnl glibc 2.35 . # . . . . . . . . . . . . . . . . . . . . . . . . . . +dnl glibc 2.5 . # . . . . # # . . . . . . . . . . . . . . . . . . # . +dnl glibc 2.3.6 . # . . . # # # . . . . . . . . . . . . . . . . . . # . +dnl FreeBSD 14.0 . . . . . # . . . . . . . . . . . . # . . . . . . # . # +dnl FreeBSD 13.0 . # . . . # # # . . . . . . . . . . # . . . . . . # . # +dnl FreeBSD 5.4, 6.1 . # . . . # # # . . . . . . . # ? . # . . . . . . # ? ? +dnl Mac OS X 10.13.5 . # . . # # # # . # . . . . . . . . . . . . # . . # ? ? +dnl Mac OS X 10.5.8 . # . . # # # # . . . . . . . # # . . . . . . . . # ? ? +dnl Mac OS X 10.3.9 . # . . . # # # . . . . . . . # # . # . . . . . . # ? ? +dnl OpenBSD 6.0, 6.7 . # . . . # # # . . . . . . . . . . # . . . . . . # . # +dnl OpenBSD 3.9, 4.0 . # . # # # # # # . # . . # . # ? . # . . . . . . # ? ? +dnl Cygwin 1.7.0 (2009) . # . . # . # # . . ? ? . . . . ? . ? . . . . . . ? ? ? +dnl Cygwin 1.5.25 (2008) . # . . # # # # . . # ? . . . . ? . # . . . . . . ? ? ? +dnl Cygwin 1.5.19 (2006) # # . . # # # # # . # ? . # . # ? # # . . . . . . ? ? ? +dnl Solaris 11.4 . # . # # # # # . . # . . . . # . . . . . . . . . . # . +dnl Solaris 11.3 . # . . . # # # . . # . . . . . . . . . . . . . . . # . +dnl Solaris 11.0 . # . # # # # # . . # . . . . # . . . . . . . . . ? ? ? +dnl Solaris 10 . # . # # # # # . . # . . . . # . # . . . . . . . . # . +dnl Solaris 2.6 ... 9 # # . # # # # # # . # . . . . # ? # . . . # . . . ? ? ? +dnl Solaris 2.5.1 # # . # # # # # # . # . . . . # ? . . # # # # # # ? ? ? +dnl AIX 7.1 . # . # # # # # . . . . . . . # . # . . . . . . . # . . +dnl AIX 5.2 . # . # # # # # . . . . . . . # ? . . . . . . . . # ? ? +dnl AIX 4.3.2, 5.1 # # . # # # # # # . . . . . . # ? . . . . # . . . # ? ? +dnl HP-UX 11.31 . # . . . # # # . . . ? . . . # ? . . . . # # . . ? ? ? +dnl HP-UX 11.{00,11,23} # # . . . # # # # . . ? . . . # ? . . . . # # . # ? ? ? +dnl HP-UX 10.20 # # . # . # # # # . ? ? . . # # ? . . . . # # ? # ? ? ? +dnl IRIX 6.5 # # . # # # # # # . # . . . . # ? . . . . # . . . # ? ? +dnl OSF/1 5.1 # # . # # # # # # . . ? . . . # ? . . . . # . . # ? ? ? +dnl OSF/1 4.0d # # . # # # # # # . . ? . . . # ? . . # # # # # # ? ? ? +dnl NetBSD 9.0 . # . . . # # # . . . . . . . . . . . . . . . . . # . # +dnl NetBSD 5.0 . # . . # # # # . . . . . . . # ? . # . . . . . . # ? ? +dnl NetBSD 4.0 . # ? ? ? ? # # ? . ? . . ? ? ? ? ? ? . . . ? ? ? # ? ? +dnl NetBSD 3.0 . # . . . # # # # . ? . # # ? # ? . # . . . . . . # ? ? +dnl Haiku . # . . # # # # # . # ? . . . . ? . ? . . ? . . . . # . +dnl BeOS # # # . # # # # # . ? ? # . ? . ? # ? . . ? . . . ? ? ? +dnl Android 4.3 . # . # # # # # # # # ? . # . # ? . # . . . # . . ? ? ? +dnl old mingw / msvcrt # # # # # # # # # . . ? # # . # ? # ? . # # # . . # ? ? +dnl MSVC 9 # # # # # # # # # # . ? # # . # ? # ? # # # # . . # ? ? +dnl mingw 2009-2011 . # # . # . # # . . . ? # # . . ? . ? . . . . . . # ? ? +dnl mingw-w64 2011 # # # # # # # # # . . ? # # . # ? # ? . # # # . . # ? ? diff --git a/gl/m4/pthread_rwlock_rdlock.m4 b/gl/m4/pthread_rwlock_rdlock.m4 index ae6a885..b8b5b11 100644 --- a/gl/m4/pthread_rwlock_rdlock.m4 +++ b/gl/m4/pthread_rwlock_rdlock.m4 @@ -1,5 +1,6 @@ -# pthread_rwlock_rdlock.m4 serial 4 -dnl Copyright (C) 2017-2023 Free Software Foundation, Inc. +# pthread_rwlock_rdlock.m4 +# serial 8 +dnl Copyright (C) 2017-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -34,11 +35,11 @@ dnl https://sourceware.org/bugzilla/show_bug.cgi?id=13701 dnl https://bugzilla.redhat.com/show_bug.cgi?id=1410052 AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], [ - AC_REQUIRE([gl_THREADLIB_EARLY]) + AC_REQUIRE([gl_THREADLIB]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader], [gl_cv_pthread_rwlock_rdlock_prefer_writer], - [save_LIBS="$LIBS" + [saved_LIBS="$LIBS" LIBS="$LIBS $LIBMULTITHREAD" AC_RUN_IFELSE( [AC_LANG_SOURCE([[ @@ -156,25 +157,25 @@ main () [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes], [gl_cv_pthread_rwlock_rdlock_prefer_writer=no], [case "$host_os" in - # Guess no on glibc systems. - *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; - # Guess no on musl systems. - *-musl*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; - # Guess no on bionic systems. - *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; - # Guess yes on native Windows with the mingw-w64 winpthreads library. - # Guess no on native Windows with the gnulib windows-rwlock module. - mingw*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then - gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes" - else - gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" - fi - ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_pthread_rwlock_rdlock_prefer_writer="$gl_cross_guess_normal" ;; + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess no on bionic systems. + *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess yes on native Windows with the mingw-w64 winpthreads library. + # Guess no on native Windows with the gnulib windows-rwlock module. + mingw* | windows*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes" + else + gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" + fi + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_pthread_rwlock_rdlock_prefer_writer="$gl_cross_guess_normal" ;; esac ]) - LIBS="$save_LIBS" + LIBS="$saved_LIBS" ]) case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in *yes) diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4 index d22138f..eb90d58 100644 --- a/gl/m4/realloc.m4 +++ b/gl/m4/realloc.m4 @@ -1,5 +1,6 @@ -# realloc.m4 serial 26 -dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. +# realloc.m4 +# serial 29 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -16,7 +17,8 @@ AC_DEFUN([_AC_FUNC_REALLOC_IF], [[#include ]], [[void *p = realloc (0, 0); - int result = !p; + void * volatile vp = p; + int result = !vp; free (p); return result;]]) ], @@ -25,8 +27,8 @@ AC_DEFUN([_AC_FUNC_REALLOC_IF], [case "$host_os" in # Guess yes on platforms where we know the result. *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ - | gnu* | *-musl* | midnightbsd* \ - | hpux* | solaris* | cygwin* | mingw* | msys* ) + | gnu* | *-musl* | midipix* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | windows* | msys* ) ac_cv_func_realloc_0_nonnull="guessing yes" ;; # If we don't know, obey --enable-cross-guesses. *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;; diff --git a/gl/m4/reallocarray.m4 b/gl/m4/reallocarray.m4 index 1607b7a..958095e 100644 --- a/gl/m4/reallocarray.m4 +++ b/gl/m4/reallocarray.m4 @@ -1,5 +1,6 @@ -# reallocarray.m4 serial 3 -dnl Copyright (C) 2017-2023 Free Software Foundation, Inc. +# reallocarray.m4 +# serial 5 +dnl Copyright (C) 2017-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -11,9 +12,12 @@ AC_DEFUN([gl_FUNC_REALLOCARRAY], AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF]) - AC_CHECK_FUNCS([reallocarray]) + gl_CHECK_FUNCS_ANDROID([reallocarray], [[#include ]]) if test "$ac_cv_func_reallocarray" = no; then HAVE_REALLOCARRAY=0 + case "$gl_cv_onwards_func_reallocarray" in + future*) REPLACE_REALLOCARRAY=1 ;; + esac elif test "$gl_cv_malloc_ptrdiff" = no; then REPLACE_REALLOCARRAY=1 fi diff --git a/gl/m4/regex.m4 b/gl/m4/regex.m4 index c89a143..f0101fe 100644 --- a/gl/m4/regex.m4 +++ b/gl/m4/regex.m4 @@ -1,10 +1,9 @@ -# serial 73 - -# Copyright (C) 1996-2001, 2003-2023 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# regex.m4 +# serial 75 +dnl Copyright (C) 1996-2001, 2003-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. dnl Initially derived from code in GNU grep. dnl Mostly written by Jim Meyering. @@ -15,7 +14,7 @@ AC_DEFUN([gl_REGEX], [ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_ARG_WITH([included-regex], - [AS_HELP_STRING([--without-included-regex], + [AS_HELP_STRING([[--without-included-regex]], [don't compile regex; this is the default on systems with recent-enough versions of the GNU C Library (use with caution on other systems).])]) @@ -327,10 +326,10 @@ AC_DEFUN([gl_REGEX], [gl_cv_func_re_compile_pattern_working=yes], [gl_cv_func_re_compile_pattern_working=no], [case "$host_os" in - # Guess no on native Windows. - mingw*) gl_cv_func_re_compile_pattern_working="guessing no" ;; - # Otherwise obey --enable-cross-guesses. - *) gl_cv_func_re_compile_pattern_working="$gl_cross_guess_normal" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_re_compile_pattern_working="guessing no" ;; + # Otherwise obey --enable-cross-guesses. + *) gl_cv_func_re_compile_pattern_working="$gl_cross_guess_normal" ;; esac ]) ]) diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4 index 0f35b8b..422003b 100644 --- a/gl/m4/servent.m4 +++ b/gl/m4/servent.m4 @@ -1,5 +1,6 @@ -# servent.m4 serial 4 -dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. +# servent.m4 +# serial 5 +dnl Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -28,7 +29,7 @@ AC_DEFUN([gl_SERVENT], AC_CACHE_CHECK([for getservbyname in winsock2.h and -lws2_32], [gl_cv_w32_getservbyname], [gl_cv_w32_getservbyname=no - gl_save_LIBS="$LIBS" + gl_saved_LIBS="$LIBS" LIBS="$LIBS -lws2_32" AC_LINK_IFELSE( [AC_LANG_PROGRAM( @@ -40,7 +41,7 @@ AC_DEFUN([gl_SERVENT], ]], [[getservbyname(NULL,NULL);]])], [gl_cv_w32_getservbyname=yes]) - LIBS="$gl_save_LIBS" + LIBS="$gl_saved_LIBS" ]) if test "$gl_cv_w32_getservbyname" = "yes"; then SERVENT_LIB="-lws2_32" diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4 index 16f9eb5..e7f00f3 100644 --- a/gl/m4/setenv.m4 +++ b/gl/m4/setenv.m4 @@ -1,5 +1,6 @@ -# setenv.m4 serial 30 -dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc. +# setenv.m4 +# serial 33 +dnl Copyright (C) 2001-2004, 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -35,12 +36,12 @@ AC_DEFUN([gl_FUNC_SETENV], ]])], [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], [case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_setenv_works="guessing yes" ;; - # Guess yes on musl systems. - *-musl*) gl_cv_func_setenv_works="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_setenv_works="$gl_cross_guess_normal" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_setenv_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_setenv_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_setenv_works="$gl_cross_guess_normal" ;; esac ])]) case "$gl_cv_func_setenv_works" in @@ -151,11 +152,10 @@ int unsetenv (const char *name); # Prerequisites of lib/setenv.c. AC_DEFUN([gl_PREREQ_SETENV], [ - AC_REQUIRE([AC_FUNC_ALLOCA]) AC_REQUIRE([gl_ENVIRON]) AC_CHECK_HEADERS_ONCE([unistd.h]) AC_CHECK_HEADERS([search.h]) - AC_CHECK_FUNCS([tsearch]) + gl_CHECK_FUNCS_ANDROID([tsearch], [[#include ]]) ]) # Prerequisites of lib/unsetenv.c. diff --git a/gl/m4/setlocale_null.m4 b/gl/m4/setlocale_null.m4 index 032119d..e5b7d28 100644 --- a/gl/m4/setlocale_null.m4 +++ b/gl/m4/setlocale_null.m4 @@ -1,5 +1,6 @@ -# setlocale_null.m4 serial 5 -dnl Copyright (C) 2019-2023 Free Software Foundation, Inc. +# setlocale_null.m4 +# serial 9 +dnl Copyright (C) 2019-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -13,11 +14,25 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL], AC_CACHE_CHECK([whether setlocale (LC_ALL, NULL) is multithread-safe], [gl_cv_func_setlocale_null_all_mtsafe], [case "$host_os" in - # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin. - *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku* | cygwin*) + # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku. + *-musl* | midipix* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku*) gl_cv_func_setlocale_null_all_mtsafe=no ;; + # Guess no on Cygwin < 3.4.6. + cygwin*) + AC_EGREP_CPP([Lucky user], + [ +#if defined __CYGWIN__ + #include + #if CYGWIN_VERSION_DLL_COMBINED >= CYGWIN_VERSION_DLL_MAKE_COMBINED (3004, 6) + Lucky user + #endif +#endif + ], + [gl_cv_func_setlocale_null_all_mtsafe=yes], + [gl_cv_func_setlocale_null_all_mtsafe=no]) + ;; # Guess yes on glibc, HP-UX, IRIX, Solaris, native Windows. - *-gnu* | gnu* | hpux* | irix* | solaris* | mingw*) + *-gnu* | gnu* | hpux* | irix* | solaris* | mingw* | windows*) gl_cv_func_setlocale_null_all_mtsafe=yes ;; # If we don't know, obey --enable-cross-guesses. *) @@ -26,7 +41,7 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL], ]) dnl On platforms without multithreading, there is no issue. case "$host_os" in - mingw*) ;; + mingw* | windows*) ;; *) if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then gl_cv_func_setlocale_null_all_mtsafe="trivially yes" @@ -48,7 +63,7 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL], openbsd* | aix*) gl_cv_func_setlocale_null_one_mtsafe=no ;; # Guess yes on glibc, musl libc, macOS, FreeBSD, NetBSD, HP-UX, IRIX, Solaris, Haiku, Cygwin, native Windows. - *-gnu* | gnu* | *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | irix* | solaris* | haiku* | cygwin* | mingw*) + *-gnu* | gnu* | *-musl* | midipix* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | irix* | solaris* | haiku* | cygwin* | mingw* | windows*) gl_cv_func_setlocale_null_one_mtsafe=yes ;; # If we don't know, obey --enable-cross-guesses. *) @@ -57,7 +72,7 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL], ]) dnl On platforms without multithreading, there is no issue. case "$host_os" in - mingw*) ;; + mingw* | windows*) ;; *) if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then gl_cv_func_setlocale_null_one_mtsafe="trivially yes" @@ -74,20 +89,25 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL], dnl Determine link dependencies of lib/setlocale_null.c and lib/setlocale-lock.c. if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then case "$host_os" in - mingw*) LIB_SETLOCALE_NULL= ;; + mingw* | windows*) + SETLOCALE_NULL_LIB= + ;; *) gl_WEAK_SYMBOLS case "$gl_cv_have_weak" in - *yes) LIB_SETLOCALE_NULL= ;; - *) LIB_SETLOCALE_NULL="$LIBPTHREAD" ;; + *yes) SETLOCALE_NULL_LIB= ;; + *) SETLOCALE_NULL_LIB="$LIBPTHREAD" ;; esac ;; esac else - LIB_SETLOCALE_NULL= + SETLOCALE_NULL_LIB= fi - dnl LIB_SETLOCALE_NULL is expected to be '-pthread' or '-lpthread' on AIX + dnl SETLOCALE_NULL_LIB is expected to be '-pthread' or '-lpthread' on AIX dnl with gcc or xlc, and empty otherwise. + AC_SUBST([SETLOCALE_NULL_LIB]) + dnl For backward compatibility. + LIB_SETLOCALE_NULL="$SETLOCALE_NULL_LIB" AC_SUBST([LIB_SETLOCALE_NULL]) ]) diff --git a/gl/m4/sha256.m4 b/gl/m4/sha256.m4 index 4d1d1dd..ad5596a 100644 --- a/gl/m4/sha256.m4 +++ b/gl/m4/sha256.m4 @@ -1,5 +1,6 @@ -# sha256.m4 serial 8 -dnl Copyright (C) 2005, 2008-2023 Free Software Foundation, Inc. +# sha256.m4 +# serial 8 +dnl Copyright (C) 2005, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4 index 0763366..df91cf0 100644 --- a/gl/m4/size_max.m4 +++ b/gl/m4/size_max.m4 @@ -1,5 +1,6 @@ -# size_max.m4 serial 12 -dnl Copyright (C) 2003, 2005-2006, 2008-2023 Free Software Foundation, Inc. +# size_max.m4 +# serial 12 +dnl Copyright (C) 2003, 2005-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/snprintf.m4 b/gl/m4/snprintf.m4 index 4b5fbdb..6dbe146 100644 --- a/gl/m4/snprintf.m4 +++ b/gl/m4/snprintf.m4 @@ -1,5 +1,6 @@ -# snprintf.m4 serial 7 -dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc. +# snprintf.m4 +# serial 7 +dnl Copyright (C) 2002-2004, 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/socketlib.m4 b/gl/m4/socketlib.m4 index a556af1..09f0116 100644 --- a/gl/m4/socketlib.m4 +++ b/gl/m4/socketlib.m4 @@ -1,5 +1,6 @@ -# socketlib.m4 serial 3 -dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. +# socketlib.m4 +# serial 4 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -18,7 +19,7 @@ AC_DEFUN([gl_SOCKETLIB], dnl defined through -lws2_32), we need to call it. AC_CACHE_CHECK([for WSAStartup], [gl_cv_func_wsastartup], [ - gl_save_LIBS="$LIBS" + gl_saved_LIBS="$LIBS" LIBS="$LIBS -lws2_32" AC_LINK_IFELSE( [AC_LANG_PROGRAM([[ @@ -33,7 +34,7 @@ AC_DEFUN([gl_SOCKETLIB], ], [gl_cv_func_wsastartup=yes], [gl_cv_func_wsastartup=no]) - LIBS="$gl_save_LIBS" + LIBS="$gl_saved_LIBS" ]) if test "$gl_cv_func_wsastartup" = "yes"; then AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) @@ -56,8 +57,8 @@ AC_DEFUN([gl_SOCKETLIB], #endif char setsockopt();]], [[setsockopt();]])], [], - [gl_save_LIBS="$LIBS" - LIBS="$gl_save_LIBS -lsocket" + [gl_saved_LIBS="$LIBS" + LIBS="$gl_saved_LIBS -lsocket" AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern #ifdef __cplusplus "C" @@ -65,7 +66,7 @@ char setsockopt();]], [[setsockopt();]])], char setsockopt();]], [[setsockopt();]])], [gl_cv_lib_socket="-lsocket"]) if test -z "$gl_cv_lib_socket"; then - LIBS="$gl_save_LIBS -lnetwork" + LIBS="$gl_saved_LIBS -lnetwork" AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern #ifdef __cplusplus "C" @@ -73,7 +74,7 @@ char setsockopt();]], [[setsockopt();]])], char setsockopt();]], [[setsockopt();]])], [gl_cv_lib_socket="-lnetwork"]) if test -z "$gl_cv_lib_socket"; then - LIBS="$gl_save_LIBS -lnet" + LIBS="$gl_saved_LIBS -lnet" AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern #ifdef __cplusplus "C" @@ -82,7 +83,7 @@ char setsockopt();]], [[setsockopt();]])], [gl_cv_lib_socket="-lnet"]) fi fi - LIBS="$gl_save_LIBS" + LIBS="$gl_saved_LIBS" ]) if test -z "$gl_cv_lib_socket"; then gl_cv_lib_socket="none needed" diff --git a/gl/m4/sockets.m4 b/gl/m4/sockets.m4 index ed9cb87..a3dfe92 100644 --- a/gl/m4/sockets.m4 +++ b/gl/m4/sockets.m4 @@ -1,5 +1,6 @@ -# sockets.m4 serial 7 -dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. +# sockets.m4 +# serial 7 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4 index 1c63a85..9ece0ab 100644 --- a/gl/m4/socklen.m4 +++ b/gl/m4/socklen.m4 @@ -1,5 +1,6 @@ -# socklen.m4 serial 11 -dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. +# socklen.m4 +# serial 11 +dnl Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4 index 6c6dc2f..c68b3ab 100644 --- a/gl/m4/sockpfaf.m4 +++ b/gl/m4/sockpfaf.m4 @@ -1,5 +1,6 @@ -# sockpfaf.m4 serial 10 -dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc. +# sockpfaf.m4 +# serial 10 +dnl Copyright (C) 2004, 2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/ssize_t.m4 b/gl/m4/ssize_t.m4 index 1c12c33..c15f948 100644 --- a/gl/m4/ssize_t.m4 +++ b/gl/m4/ssize_t.m4 @@ -1,23 +1,38 @@ -# ssize_t.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2001-2003, 2006, 2010-2023 Free Software Foundation, Inc. +# ssize_t.m4 +# serial 6 +dnl Copyright (C) 2001-2003, 2006, 2010-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. -dnl Test whether ssize_t is defined. +dnl Define ssize_t if it does not already exist. AC_DEFUN([gt_TYPE_SSIZE_T], [ - AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t], + AC_CACHE_CHECK([for ssize_t], [gl_cv_ssize_t], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[#include ]], [[int x = sizeof (ssize_t *) + sizeof (ssize_t); return !x;]])], - [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])]) - if test $gt_cv_ssize_t = no; then - AC_DEFINE([ssize_t], [int], - [Define as a signed type of the same size as size_t.]) + [gl_cv_ssize_t=yes], [gl_cv_ssize_t=no])]) + if test $gl_cv_ssize_t = no; then + dnl On 64-bit native Windows, ssize_t needs to be defined as 'long long', + dnl for consistency with the 64-bit size_t. + AC_CACHE_CHECK([whether size_t is wider than 'long'], [gl_cv_size_t_large], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + typedef int array [2 * (sizeof (size_t) > sizeof (long)) - 1]; + ]])], + [gl_cv_size_t_large=yes], [gl_cv_size_t_large=no])]) + if test $gl_cv_size_t_large = yes; then + gl_def_ssize_t='long long' + else + gl_def_ssize_t='long' + fi + AC_DEFINE_UNQUOTED([ssize_t], [$gl_def_ssize_t], + [Define as a signed type of the same size as size_t.]) fi ]) diff --git a/gl/m4/stat-time.m4 b/gl/m4/stat-time.m4 index 40993d5..e8ee7d5 100644 --- a/gl/m4/stat-time.m4 +++ b/gl/m4/stat-time.m4 @@ -1,11 +1,11 @@ -# Checks for stat-related time functions. - -# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2023 Free Software -# Foundation, Inc. +# stat-time.m4 +# serial 1 +dnl Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# Checks for stat-related time functions. dnl From Paul Eggert. diff --git a/gl/m4/stat.m4 b/gl/m4/stat.m4 index 4d241e2..fabd360 100644 --- a/gl/m4/stat.m4 +++ b/gl/m4/stat.m4 @@ -1,10 +1,9 @@ -# serial 18 - -# Copyright (C) 2009-2023 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# stat.m4 +# serial 21 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_STAT], [ @@ -12,7 +11,7 @@ AC_DEFUN([gl_FUNC_STAT], AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) AC_CHECK_FUNCS_ONCE([lstat]) case "$host_os" in - mingw*) + mingw* | windows*) dnl On this platform, the original stat() returns st_atime, st_mtime, dnl st_ctime values that are affected by the time zone. REPLACE_STAT=1 @@ -45,6 +44,8 @@ AC_DEFUN([gl_FUNC_STAT], [case "$host_os" in # Guess yes on Linux systems. linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_stat_file_slash="guessing yes" ;; # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;; # If we don't know, obey --enable-cross-guesses. @@ -59,8 +60,8 @@ AC_DEFUN([gl_FUNC_STAT], help when passed a file name with a trailing slash]);; esac case $host_os in - dnl Solaris stat can return a negative tv_nsec. - solaris*) + dnl macOS and Solaris stat can return a negative tv_nsec. + darwin* | solaris*) REPLACE_FSTAT=1 ;; esac ;; @@ -78,7 +79,7 @@ AC_DEFUN([gl_PREREQ_STAT], [ AC_DEFUN([gl_PREREQ_STAT_W32], [ AC_REQUIRE([AC_CANONICAL_HOST]) case "$host_os" in - mingw*) + mingw* | windows*) AC_CHECK_HEADERS([sdkddkver.h]) ;; esac diff --git a/gl/m4/std-gnu11.m4 b/gl/m4/std-gnu11.m4 index 4179470..37324c1 100644 --- a/gl/m4/std-gnu11.m4 +++ b/gl/m4/std-gnu11.m4 @@ -1,3 +1,6 @@ +# std-gnu11.m4 +# serial 1 + # Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*- # This implementation is taken from GNU Autoconf lib/autoconf/c.m4 @@ -9,7 +12,7 @@ m4_version_prereq([2.70], [], [ -# Copyright (C) 2001-2023 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4 index dc29717..2b4762f 100644 --- a/gl/m4/stdalign.m4 +++ b/gl/m4/stdalign.m4 @@ -1,20 +1,24 @@ -# Check for alignas and alignof that conform to C23. - -dnl Copyright 2011-2023 Free Software Foundation, Inc. +# stdalign.m4 +# serial 1 +dnl Copyright 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +# Check for alignas and alignof that conform to C23. + +dnl Written by Paul Eggert and Bruno Haible. + # Prepare for substituting if it is not supported. -AC_DEFUN([gl_STDALIGN_H], +AC_DEFUN([gl_ALIGNASOF], [ AC_CACHE_CHECK([for alignas and alignof], [gl_cv_header_working_stdalign_h], - [gl_save_CFLAGS=$CFLAGS + [gl_saved_CFLAGS=$CFLAGS for gl_working in "yes, keywords" "yes, macros"; do AS_CASE([$gl_working], - [*stdalign.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_STDALIGN_H"]) + [*stdalign.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_STDALIGN_H"]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[#include @@ -54,85 +58,151 @@ AC_DEFUN([gl_STDALIGN_H], [gl_cv_header_working_stdalign_h=$gl_working], [gl_cv_header_working_stdalign_h=no]) - CFLAGS=$gl_save_CFLAGS + CFLAGS=$gl_saved_CFLAGS test "$gl_cv_header_working_stdalign_h" != no && break done]) - GL_GENERATE_STDALIGN_H=false AS_CASE([$gl_cv_header_working_stdalign_h], - [no], - [GL_GENERATE_STDALIGN_H=true], [yes*keyword*], [AC_DEFINE([HAVE_C_ALIGNASOF], [1], [Define to 1 if the alignas and alignof keywords work.])]) - AC_CHECK_HEADERS_ONCE([stdalign.h]) - dnl The "zz" puts this toward config.h's end, to avoid potential dnl collisions with other definitions. AH_VERBATIM([zzalignas], -[#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof -# if HAVE_STDALIGN_H +[#if !defined HAVE_C_ALIGNASOF \ + && !(defined __cplusplus && 201103 <= __cplusplus) \ + && !defined alignof +# if defined HAVE_STDALIGN_H # include -# else - /* Substitute. Keep consistent with gnulib/lib/stdalign.in.h. */ -# ifndef _GL_STDALIGN_H -# define _GL_STDALIGN_H -# undef _Alignas -# undef _Alignof -# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ - || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ - && !defined __clang__) \ - || (defined __clang__ && __clang_major__ < 8)) -# ifdef __cplusplus -# if (201103 <= __cplusplus || defined _MSC_VER) -# define _Alignof(type) alignof (type) -# else - template struct __alignof_helper { char __a; __t __b; }; -# define _Alignof(type) offsetof (__alignof_helper, __b) -# define _GL_STDALIGN_NEEDS_STDDEF 1 -# endif +# endif + +/* ISO C23 alignas and alignof for platforms that lack it. + + References: + ISO C23 (latest free draft + ) + sections 6.5.3.4, 6.7.5, 7.15. + C++11 (latest free draft + ) + section 18.10. */ + +/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment + requirement of a structure member (i.e., slot or field) that is of + type TYPE, as an integer constant expression. + + This differs from GCC's and clang's __alignof__ operator, which can + yield a better-performing alignment for an object of that type. For + example, on x86 with GCC and on Linux/x86 with clang, + __alignof__ (double) and __alignof__ (long long) are 8, whereas + alignof (double) and alignof (long long) are 4 unless the option + '-malign-double' is used. + + The result cannot be used as a value for an 'enum' constant, if you + want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ + +/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 + . + clang versions < 8.0.0 have the same bug. */ +# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ + && !defined __clang__) \ + || (defined __clang__ && __clang_major__ < 8)) +# undef/**/_Alignof +# ifdef __cplusplus +# if (201103 <= __cplusplus || defined _MSC_VER) +# define _Alignof(type) alignof (type) # else + template struct __alignof_helper { char __a; __t __b; }; # if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ -# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) +# define _Alignof(type) __builtin_offsetof (__alignof_helper, __b) # else -# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) -# define _GL_STDALIGN_NEEDS_STDDEF 1 +# define _Alignof(type) offsetof (__alignof_helper, __b) # endif +# define _GL_STDALIGN_NEEDS_STDDEF 1 # endif -# endif -# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) -# define alignof _Alignof -# endif -# define __alignof_is_defined 1 -# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 -# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER) -# define _Alignas(a) alignas (a) -# elif (!defined __attribute__ \ - && ((defined __APPLE__ && defined __MACH__ \ - ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ - : __GNUC__ && !defined __ibmxl__) \ - || (4 <= __clang_major__) \ - || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \ - || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)) -# define _Alignas(a) __attribute__ ((__aligned__ (a))) -# elif 1300 <= _MSC_VER -# define _Alignas(a) __declspec (align (a)) +# else +# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ +# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) +# else +# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +# define _GL_STDALIGN_NEEDS_STDDEF 1 # endif # endif -# if ((defined _Alignas \ - && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \ - || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) -# define alignas _Alignas -# endif -# if (defined alignas \ - || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) -# define __alignas_is_defined 1 -# endif -# if _GL_STDALIGN_NEEDS_STDDEF -# include -# endif -# endif /* _GL_STDALIGN_H */ +# endif +# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) +# undef/**/alignof +# define alignof _Alignof +# endif + +/* alignas (A), also known as _Alignas (A), aligns a variable or type + to the alignment A, where A is an integer constant expression. For + example: + + int alignas (8) foo; + struct s { int a; int alignas (8) bar; }; + + aligns the address of FOO and the offset of BAR to be multiples of 8. + + A should be a power of two that is at least the type's alignment + and at most the implementation's alignment limit. This limit is + 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable + to MSVC through at least version 10.0, A should be an integer + constant, as MSVC does not support expressions such as 1 << 3. + To be portable to Sun C 5.11, do not align auto variables to + anything stricter than their default alignment. + + The following C23 requirements are not supported here: + + - If A is zero, alignas has no effect. + - alignas can be used multiple times; the strictest one wins. + - alignas (TYPE) is equivalent to alignas (alignof (TYPE)). + + */ +# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 +# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER) +# define _Alignas(a) alignas (a) +# elif (!defined __attribute__ \ + && ((defined __APPLE__ && defined __MACH__ \ + ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ + : __GNUC__ && !defined __ibmxl__) \ + || (4 <= __clang_major__) \ + || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \ + || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)) +# define _Alignas(a) __attribute__ ((__aligned__ (a))) +# elif 1300 <= _MSC_VER +# define _Alignas(a) __declspec (align (a)) +# endif +# endif +# if !defined HAVE_STDALIGN_H +# if ((defined _Alignas \ + && !(defined __cplusplus \ + && (201103 <= __cplusplus || defined _MSC_VER))) \ + || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) +# define alignas _Alignas +# endif +# endif + +# if defined _GL_STDALIGN_NEEDS_STDDEF +# include # endif #endif]) ]) + +AC_DEFUN([gl_STDALIGN_H], +[ + AC_REQUIRE([gl_ALIGNASOF]) + if test "$gl_cv_header_working_stdalign_h" = no; then + GL_GENERATE_STDALIGN_H=true + else + GL_GENERATE_STDALIGN_H=false + fi + + gl_CHECK_NEXT_HEADERS([stdalign.h]) + if test $ac_cv_header_stdalign_h = yes; then + HAVE_STDALIGN_H=1 + else + HAVE_STDALIGN_H=0 + fi + AC_SUBST([HAVE_STDALIGN_H]) +]) diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4 index a2322eb..84d3bae 100644 --- a/gl/m4/stddef_h.m4 +++ b/gl/m4/stddef_h.m4 @@ -1,5 +1,6 @@ -# stddef_h.m4 serial 13 -dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. +# stddef_h.m4 +# serial 14 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -68,6 +69,21 @@ AC_DEFUN_ONCE([gl_STDDEF_H], GL_GENERATE_STDDEF_H=true fi + AC_CACHE_CHECK([for unreachable], + [gl_cv_func_unreachable], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[unreachable (); + ]])], + [gl_cv_func_unreachable=yes], + [gl_cv_func_unreachable=no]) + ]) + if test $gl_cv_func_unreachable = no; then + GL_GENERATE_STDDEF_H=true + fi + if $GL_GENERATE_STDDEF_H; then gl_NEXT_HEADERS([stddef.h]) fi diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4 index d6961b0..2dea846 100644 --- a/gl/m4/stdint.m4 +++ b/gl/m4/stdint.m4 @@ -1,5 +1,6 @@ -# stdint.m4 serial 61 -dnl Copyright (C) 2001-2023 Free Software Foundation, Inc. +# stdint.m4 +# serial 63 +dnl Copyright (C) 2001-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -150,7 +151,10 @@ intmax_t i = INTMAX_MAX; uintmax_t j = UINTMAX_MAX; /* Check that SIZE_MAX has the correct type, if possible. */ -#if 201112 <= __STDC_VERSION__ +/* ISO C 11 mandates _Generic, but GCC versions < 4.9 lack it. */ +#if 201112 <= __STDC_VERSION__ \ + && (!defined __GNUC__ || 4 < __GNUC__ + (9 <= __GNUC_MINOR__) \ + || defined __clang__) int k = _Generic (SIZE_MAX, size_t: 0); #elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \ || (0x5110 <= __SUNPRO_C && !__STDC__)) @@ -283,10 +287,10 @@ static const char *macro_values[] = [gl_cv_header_working_stdint_h=yes], [], [case "$host_os" in - # Guess yes on native Windows. - mingw*) gl_cv_header_working_stdint_h="guessing yes" ;; - # In general, assume it works. - *) gl_cv_header_working_stdint_h="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_header_working_stdint_h="guessing yes" ;; + # In general, assume it works. + *) gl_cv_header_working_stdint_h="guessing yes" ;; esac ]) ]) diff --git a/gl/m4/stdint_h.m4 b/gl/m4/stdint_h.m4 index 70349f6..29f4216 100644 --- a/gl/m4/stdint_h.m4 +++ b/gl/m4/stdint_h.m4 @@ -1,5 +1,6 @@ -# stdint_h.m4 serial 9 -dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc. +# stdint_h.m4 +# serial 9 +dnl Copyright (C) 1997-2004, 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4 index 94271e1..8eb5816 100644 --- a/gl/m4/stdio_h.m4 +++ b/gl/m4/stdio_h.m4 @@ -1,12 +1,23 @@ -# stdio_h.m4 serial 59 -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# stdio_h.m4 +# serial 63 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -AC_DEFUN_ONCE([gl_STDIO_H], +AC_DEFUN([gl_STDIO_H_EARLY], [ - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + dnl Defining __USE_MINGW_ANSI_STDIO to 1 must be done early, because + dnl the results of several configure tests depend on it: The tests + dnl - checking whether snprintf returns a byte count as in C99... + dnl - checking whether snprintf truncates the result as in C99... + dnl - checking whether printf supports the 'F' directive... + dnl - checking whether printf supports the grouping flag... + dnl - checking whether printf supports the zero flag correctly... + dnl - checking whether printf supports infinite 'double' arguments... + dnl - checking whether printf supports large precisions... + dnl report 'yes' if __USE_MINGW_ANSI_STDIO is 1 but 'no' if + dnl __USE_MINGW_ANSI_STDIO is not set. AH_VERBATIM([MINGW_ANSI_STDIO], [/* Use GNU style printf and scanf. */ #ifndef __USE_MINGW_ANSI_STDIO @@ -14,6 +25,11 @@ AC_DEFUN_ONCE([gl_STDIO_H], #endif ]) AC_DEFINE([__USE_MINGW_ANSI_STDIO]) +]) + +AC_DEFUN_ONCE([gl_STDIO_H], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) gl_NEXT_HEADERS([stdio.h]) dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and @@ -40,6 +56,9 @@ AC_DEFUN_ONCE([gl_STDIO_H], attribute "__gnu_printf__" instead of "__printf__"]) fi + dnl For defining _PRINTF_NAN_LEN_MAX. + gl_MUSL_LIBC + dnl This ifdef is an optimization, to avoid performing a configure check whose dnl result is not used. But it does not make the test of dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant. @@ -82,6 +101,16 @@ AC_DEFUN_ONCE([gl_STDIO_H], if test $ac_cv_have_decl_fcloseall = no; then HAVE_DECL_FCLOSEALL=0 fi + + AC_CHECK_DECLS_ONCE([getw]) + if test $ac_cv_have_decl_getw = no; then + HAVE_DECL_GETW=0 + fi + + AC_CHECK_DECLS_ONCE([putw]) + if test $ac_cv_have_decl_putw = no; then + HAVE_DECL_PUTW=0 + fi ]) # gl_STDIO_MODULE_INDICATOR([modulename]) @@ -178,7 +207,9 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM]) HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE]) + HAVE_DECL_GETW=1; AC_SUBST([HAVE_DECL_GETW]) HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF]) + HAVE_DECL_PUTW=1; AC_SUBST([HAVE_DECL_PUTW]) HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF]) HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF]) HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF]) diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4 index e96be22..a4662f2 100644 --- a/gl/m4/stdlib_h.m4 +++ b/gl/m4/stdlib_h.m4 @@ -1,5 +1,6 @@ -# stdlib_h.m4 serial 66 -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# stdlib_h.m4 +# serial 77 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -23,15 +24,58 @@ AC_DEFUN_ONCE([gl_STDLIB_H], # include #endif ]], [_Exit aligned_alloc atoll canonicalize_file_name free - getloadavg getsubopt grantpt - initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps - posix_memalign posix_openpt ptsname ptsname_r qsort_r + getloadavg getprogname getsubopt grantpt + initstate initstate_r mbstowcs mbtowc mkdtemp mkostemp mkostemps mkstemp + mkstemps posix_memalign posix_openpt ptsname ptsname_r qsort_r random random_r reallocarray realpath rpmatch secure_getenv setenv setstate setstate_r srandom srandom_r strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv]) AC_REQUIRE([AC_C_RESTRICT]) + dnl Test whether MB_CUR_MAX needs to be overridden. + dnl On Solaris 10, in UTF-8 locales, its value is 3 but needs to be 4. + dnl Fortunately, we can do this because on this platform MB_LEN_MAX is 5. + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_CACHE_CHECK([whether MB_CUR_MAX is correct], + [gl_cv_macro_MB_CUR_MAX_good], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on Solaris. + solaris*) gl_cv_macro_MB_CUR_MAX_good="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_macro_MB_CUR_MAX_good="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR_UTF8 != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +int main () +{ + int result = 0; + if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + if (MB_CUR_MAX < 4) + result |= 1; + } + return result; +}]])], + [gl_cv_macro_MB_CUR_MAX_good=yes], + [gl_cv_macro_MB_CUR_MAX_good=no], + [:]) + fi + ]) + case "$gl_cv_macro_MB_CUR_MAX_good" in + *yes) ;; + *) REPLACE_MB_CUR_MAX=1 ;; + esac + AC_CHECK_DECLS_ONCE([ecvt]) if test $ac_cv_have_decl_ecvt = no; then HAVE_DECL_ECVT=0 @@ -73,10 +117,12 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPROGNAME]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOWCS]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP]) @@ -89,6 +135,7 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME_R]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTENV]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_QSORT_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAND]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY]) @@ -99,6 +146,7 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SECURE_GETENV]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETENV]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLD]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLL]) @@ -130,6 +178,8 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT]) HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT]) HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) + HAVE_DECL_PROGRAM_INVOCATION_NAME=1; AC_SUBST([HAVE_DECL_PROGRAM_INVOCATION_NAME]) + HAVE_GETPROGNAME=1; AC_SUBST([HAVE_GETPROGNAME]) HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE]) @@ -157,6 +207,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE]) HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE]) HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) + HAVE_STRTOF=1; AC_SUBST([HAVE_STRTOF]) HAVE_STRTOL=1; AC_SUBST([HAVE_STRTOL]) HAVE_STRTOLD=1; AC_SUBST([HAVE_STRTOLD]) HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) @@ -166,21 +217,31 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) + REPLACE__EXIT=0; AC_SUBST([REPLACE__EXIT]) REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC]) REPLACE_CALLOC_FOR_CALLOC_GNU=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU]) REPLACE_CALLOC_FOR_CALLOC_POSIX=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX]) REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) REPLACE_FREE=0; AC_SUBST([REPLACE_FREE]) + REPLACE_GETLOADAVG=0; AC_SUBST([REPLACE_GETLOADAVG]) + REPLACE_GETPROGNAME=0; AC_SUBST([REPLACE_GETPROGNAME]) + REPLACE_GETSUBOPT=0; AC_SUBST([REPLACE_GETSUBOPT]) REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE]) REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU]) REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX]) + REPLACE_MB_CUR_MAX=0; AC_SUBST([REPLACE_MB_CUR_MAX]) + REPLACE_MBSTOWCS=0; AC_SUBST([REPLACE_MBSTOWCS]) REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) + REPLACE_MKOSTEMP=0; AC_SUBST([REPLACE_MKOSTEMP]) + REPLACE_MKOSTEMPS=0; AC_SUBST([REPLACE_MKOSTEMPS]) REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) REPLACE_POSIX_MEMALIGN=0; AC_SUBST([REPLACE_POSIX_MEMALIGN]) + REPLACE_POSIX_OPENPT=0; AC_SUBST([REPLACE_POSIX_OPENPT]) REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME]) REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R]) + REPLACE_RAND=0; AC_SUBST([REPLACE_RAND]) REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM]) REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU]) @@ -190,6 +251,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE]) REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) + REPLACE_STRTOF=0; AC_SUBST([REPLACE_STRTOF]) REPLACE_STRTOL=0; AC_SUBST([REPLACE_STRTOL]) REPLACE_STRTOLD=0; AC_SUBST([REPLACE_STRTOLD]) REPLACE_STRTOLL=0; AC_SUBST([REPLACE_STRTOLL]) diff --git a/gl/m4/strcase.m4 b/gl/m4/strcase.m4 index 3cf740d..6302173 100644 --- a/gl/m4/strcase.m4 +++ b/gl/m4/strcase.m4 @@ -1,5 +1,6 @@ -# strcase.m4 serial 12 -dnl Copyright (C) 2002, 2005-2023 Free Software Foundation, Inc. +# strcase.m4 +# serial 12 +dnl Copyright (C) 2002, 2005-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/strcasestr.m4 b/gl/m4/strcasestr.m4 index 971e0b2..d254871 100644 --- a/gl/m4/strcasestr.m4 +++ b/gl/m4/strcasestr.m4 @@ -1,5 +1,6 @@ -# strcasestr.m4 serial 28 -dnl Copyright (C) 2005, 2007-2023 Free Software Foundation, Inc. +# strcasestr.m4 +# serial 28 +dnl Copyright (C) 2005, 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/strerror.m4 b/gl/m4/strerror.m4 index 8879eb0..0272c6f 100644 --- a/gl/m4/strerror.m4 +++ b/gl/m4/strerror.m4 @@ -1,5 +1,6 @@ -# strerror.m4 serial 23 -dnl Copyright (C) 2002, 2007-2023 Free Software Foundation, Inc. +# strerror.m4 +# serial 25 +dnl Copyright (C) 2002, 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -24,12 +25,12 @@ AC_DEFUN([gl_FUNC_STRERROR], [gl_cv_func_working_strerror=yes], [gl_cv_func_working_strerror=no], [case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_working_strerror="guessing yes" ;; - # Guess yes on musl systems. - *-musl*) gl_cv_func_working_strerror="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_working_strerror="$gl_cross_guess_normal" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_working_strerror="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_working_strerror="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_working_strerror="$gl_cross_guess_normal" ;; esac ]) ]) @@ -80,14 +81,14 @@ AC_DEFUN([gl_FUNC_STRERROR_0], [gl_cv_func_strerror_0_works=yes], [gl_cv_func_strerror_0_works=no], [case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; - # Guess yes on musl systems. - *-musl*) gl_cv_func_strerror_0_works="guessing yes" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_strerror_0_works="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_strerror_0_works="$gl_cross_guess_normal" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_strerror_0_works="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_strerror_0_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_strerror_0_works="$gl_cross_guess_normal" ;; esac ]) ]) diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4 index 5da3cc2..f31264a 100644 --- a/gl/m4/string_h.m4 +++ b/gl/m4/string_h.m4 @@ -1,11 +1,11 @@ -# Configure a GNU-like replacement for . - -# Copyright (C) 2007-2023 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# string_h.m4 +# serial 39 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -# serial 35 +# Configure a GNU-like replacement for . # Written by Paul Eggert. @@ -131,6 +131,9 @@ AC_DEFUN([gl_STRING_H_DEFAULTS], REPLACE_FFSLL=0; AC_SUBST([REPLACE_FFSLL]) REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) + REPLACE_MEMPCPY=0; AC_SUBST([REPLACE_MEMPCPY]) + REPLACE_MEMSET_EXPLICIT=0; AC_SUBST([REPLACE_MEMSET_EXPLICIT]) + REPLACE_STPCPY=0; AC_SUBST([REPLACE_STPCPY]) REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL]) REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) @@ -144,5 +147,6 @@ AC_DEFUN([gl_STRING_H_DEFAULTS], REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) REPLACE_STRERRORNAME_NP=0; AC_SUBST([REPLACE_STRERRORNAME_NP]) REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) + REPLACE_STRVERSCMP=0; AC_SUBST([REPLACE_STRVERSCMP]) UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) ]) diff --git a/gl/m4/strings_h.m4 b/gl/m4/strings_h.m4 index 4c41221..aaafb55 100644 --- a/gl/m4/strings_h.m4 +++ b/gl/m4/strings_h.m4 @@ -1,10 +1,11 @@ -# Configure a replacement for . +# strings_h.m4 # serial 9 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -# Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# Configure a replacement for . AC_DEFUN_ONCE([gl_STRINGS_H], [ diff --git a/gl/m4/strsep.m4 b/gl/m4/strsep.m4 index e0da09a..cfde87a 100644 --- a/gl/m4/strsep.m4 +++ b/gl/m4/strsep.m4 @@ -1,5 +1,6 @@ -# strsep.m4 serial 11 -dnl Copyright (C) 2002-2004, 2007, 2009-2023 Free Software Foundation, Inc. +# strsep.m4 +# serial 11 +dnl Copyright (C) 2002-2004, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/strstr.m4 b/gl/m4/strstr.m4 index 7de203a..957ed2e 100644 --- a/gl/m4/strstr.m4 +++ b/gl/m4/strstr.m4 @@ -1,5 +1,6 @@ -# strstr.m4 serial 24 -dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. +# strstr.m4 +# serial 24 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4 index 98a1041..3bf3cb4 100644 --- a/gl/m4/sys_socket_h.m4 +++ b/gl/m4/sys_socket_h.m4 @@ -1,5 +1,6 @@ -# sys_socket_h.m4 serial 29 -dnl Copyright (C) 2005-2023 Free Software Foundation, Inc. +# sys_socket_h.m4 +# serial 29 +dnl Copyright (C) 2005-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4 index ca57398..3cc50ce 100644 --- a/gl/m4/sys_stat_h.m4 +++ b/gl/m4/sys_stat_h.m4 @@ -1,5 +1,6 @@ -# sys_stat_h.m4 serial 42 -*- Autoconf -*- -dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. +# sys_stat_h.m4 +# serial 42 -*- Autoconf -*- +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sys_types_h.m4 b/gl/m4/sys_types_h.m4 index 627671f..00d2437 100644 --- a/gl/m4/sys_types_h.m4 +++ b/gl/m4/sys_types_h.m4 @@ -1,5 +1,6 @@ -# sys_types_h.m4 serial 13 -dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. +# sys_types_h.m4 +# serial 13 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/sys_uio_h.m4 b/gl/m4/sys_uio_h.m4 index 93a65d2..a471c72 100644 --- a/gl/m4/sys_uio_h.m4 +++ b/gl/m4/sys_uio_h.m4 @@ -1,5 +1,6 @@ -# sys_uio_h.m4 serial 3 -dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. +# sys_uio_h.m4 +# serial 3 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4 index b536b04..f5e8147 100644 --- a/gl/m4/threadlib.m4 +++ b/gl/m4/threadlib.m4 @@ -1,5 +1,6 @@ -# threadlib.m4 serial 32a -dnl Copyright (C) 2005-2023 Free Software Foundation, Inc. +# threadlib.m4 +# serial 42 +dnl Copyright (C) 2005-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -85,10 +86,11 @@ AC_DEFUN([gl_WEAK_SYMBOLS], AC_CACHE_CHECK([whether imported symbols can be declared weak], [gl_cv_have_weak], [case "$host_os" in - cygwin*) - dnl On Cygwin 3.2.0 with gcc 10.2, the test below would succeed, but - dnl programs that use pthread_in_use() with weak symbol references - dnl crash miserably at runtime. + cygwin* | mingw* | windows*) + dnl On Cygwin 3.2.0 with gcc 10.2, and likewise on mingw 10.0.0 with + dnl gcc 11.3, the test below would succeed, but programs that use + dnl pthread_in_use() with weak symbol references crash miserably at + dnl runtime. gl_cv_have_weak="guessing no" ;; *) @@ -174,7 +176,7 @@ dnl Sets the variable LIBPMULTITHREAD, for programs that really need dnl multithread functionality. The difference between LIBPTHREAD and dnl LIBPMULTITHREAD is that on platforms supporting weak symbols, typically dnl LIBPTHREAD is empty whereas LIBPMULTITHREAD is not. -dnl Sets the variable LIB_SCHED_YIELD to the linker options needed to use the +dnl Sets the variable SCHED_YIELD_LIB to the linker options needed to use the dnl sched_yield() function. dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for dnl multithread-safe programs. @@ -205,7 +207,7 @@ AC_DEFUN([gl_PTHREADLIB_BODY], # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 # needs -pthread for some reason. See: # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html - save_LIBS=$LIBS + saved_LIBS="$LIBS" for gl_pthread in '' '-pthread'; do LIBS="$LIBS $gl_pthread" AC_LINK_IFELSE( @@ -219,7 +221,7 @@ AC_DEFUN([gl_PTHREADLIB_BODY], [gl_pthread_api=yes LIBPTHREAD=$gl_pthread LIBPMULTITHREAD=$gl_pthread]) - LIBS=$save_LIBS + LIBS="$saved_LIBS" test $gl_pthread_api = yes && break done echo "$as_me:__oline__: gl_pthread_api=$gl_pthread_api" >&AS_MESSAGE_LOG_FD @@ -268,6 +270,15 @@ changequote([,])dnl [Define if the pthread_in_use() detection is hard.]) esac fi + ], + [dnl This is needed on FreeBSD 5.2.1. + AC_CHECK_LIB([thr], [pthread_kill], + [if test $gl_pthread_in_glibc = yes; then + LIBPMULTITHREAD= + else + LIBPMULTITHREAD=-lthr + fi + ]) ]) elif test $gl_pthread_api != yes; then # Some library is needed. Try libpthread and libc_r. @@ -299,13 +310,16 @@ changequote([,])dnl [AC_LANG_PROGRAM( [[#include ]], [[sched_yield ();]])], - [LIB_SCHED_YIELD= + [SCHED_YIELD_LIB= ], [dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc. - AC_CHECK_LIB([rt], [sched_yield], [LIB_SCHED_YIELD=-lrt], + AC_CHECK_LIB([rt], [sched_yield], [SCHED_YIELD_LIB=-lrt], [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt. - AC_CHECK_LIB([posix4], [sched_yield], [LIB_SCHED_YIELD=-lposix4])]) + AC_CHECK_LIB([posix4], [sched_yield], [SCHED_YIELD_LIB=-lposix4])]) ]) + AC_SUBST([SCHED_YIELD_LIB]) + dnl For backward compatibility. + LIB_SCHED_YIELD="$SCHED_YIELD_LIB" AC_SUBST([LIB_SCHED_YIELD]) gl_pthreadlib_body_done=done @@ -340,7 +354,7 @@ AC_DEFUN([gl_STDTHREADLIB_BODY], AC_CHECK_HEADERS_ONCE([threads.h]) case "$host_os" in - mingw*) + mingw* | windows*) LIBSTDTHREAD= ;; *) @@ -351,7 +365,7 @@ AC_DEFUN([gl_STDTHREADLIB_BODY], dnl on libpthread (for the symbol 'pthread_mutexattr_gettype'). dnl glibc >= 2.34, AIX >= 7.1, and Solaris >= 11.4 have thrd_create in dnl libc. - AC_CHECK_FUNCS([thrd_create]) + gl_CHECK_FUNCS_ANDROID([thrd_create], [[#include ]]) if test $ac_cv_func_thrd_create = yes; then LIBSTDTHREAD= else @@ -364,7 +378,7 @@ AC_DEFUN([gl_STDTHREADLIB_BODY], fi else dnl Libraries needed by thrd.c, mtx.c, cnd.c, tss.c. - LIBSTDTHREAD="$LIBPMULTITHREAD $LIB_SCHED_YIELD" + LIBSTDTHREAD="$LIBPMULTITHREAD $SCHED_YIELD_LIB" fi ;; esac @@ -435,10 +449,12 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY], m4_ifdef([gl_THREADLIB_DEFAULT_NO], [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) - m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=]) + dnl gl_use_winpthreads_default defaults to 'no', because in mingw 10, like + dnl in mingw 5, the use of libwinpthread still makes test-pthread-tss crash. + m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=no]) AC_ARG_ENABLE([threads], -AS_HELP_STRING([--enable-threads={isoc|posix|isoc+posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ -AS_HELP_STRING([--disable-threads], [build without multithread safety])]), +AS_HELP_STRING([[--enable-threads={isoc|posix|isoc+posix|windows}]], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ +AS_HELP_STRING([[--disable-threads]], [build without multithread safety])]), [gl_use_threads=$enableval], [if test -n "$gl_use_threads_default"; then gl_use_threads="$gl_use_threads_default" @@ -459,7 +475,7 @@ changequote(,)dnl esac ;; dnl Obey gl_AVOID_WINPTHREAD on mingw. - mingw*) + mingw* | windows*) case "$gl_use_winpthreads_default" in yes) gl_use_threads=posix ;; no) gl_use_threads=windows ;; @@ -558,7 +574,7 @@ AC_DEFUN([gl_THREADLIB_BODY], case "$gl_use_threads" in yes | windows | win32) # The 'win32' is for backward compatibility. if { case "$host_os" in - mingw*) true;; + mingw* | windows*) true;; *) false;; esac }; then @@ -569,6 +585,10 @@ AC_DEFUN([gl_THREADLIB_BODY], ;; esac fi + else + dnl "$gl_use_threads" is "no". + AC_DEFINE([AVOID_ANY_THREADS], [1], + [Define if no multithread safety and no multithreading is desired.]) fi AC_MSG_CHECKING([for multithread API to use]) AC_MSG_RESULT([$gl_threads_api]) @@ -601,7 +621,8 @@ dnl ------------------- dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided. dnl The user can still override it at installation time, by using the -dnl configure option '--enable-threads'. +dnl configure option '--enable-threads=posix'. +dnl As of 2023, this is now the default. AC_DEFUN([gl_AVOID_WINPTHREAD], [ m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no]) diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4 index f6bf3a4..d2f3c97 100644 --- a/gl/m4/time_h.m4 +++ b/gl/m4/time_h.m4 @@ -1,12 +1,11 @@ -# Configure a more-standard replacement for . - -# Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc. - -# serial 20 +# time_h.m4 +# serial 25 +dnl Copyright (C) 2000-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# Configure a more-standard replacement for . # Written by Paul Eggert and Jim Meyering. @@ -23,7 +22,10 @@ AC_DEFUN_ONCE([gl_TIME_H], dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[ #include - ]], [asctime_r ctime_r]) + ]], [ + asctime asctime_r ctime ctime_r gmtime_r localtime localtime_r mktime + nanosleep strftime strptime time timegm timespec_get timespec_getres tzset + ]) AC_REQUIRE([AC_C_RESTRICT]) @@ -137,6 +139,7 @@ AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES]) @@ -161,23 +164,16 @@ AC_DEFUN([gl_TIME_H_DEFAULTS], HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES]) dnl Even GNU libc does not have timezone_t yet. HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T]) - dnl If another module says to replace or to not replace, do that. - dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; - dnl this lets maintainers check for portability. - REPLACE_CTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_CTIME]) - REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) - REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) - REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) - REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME]) - REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) - REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET]) - - dnl Hack so that the time module doesn't depend on the sys_time module. - dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent. - : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY]) - dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME - dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier - dnl is no longer a big deal. + REPLACE_CTIME=0; AC_SUBST([REPLACE_CTIME]) REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME]) REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME]) + REPLACE_LOCALTIME_R=0; AC_SUBST([REPLACE_LOCALTIME_R]) + REPLACE_MKTIME=0; AC_SUBST([REPLACE_MKTIME]) + REPLACE_NANOSLEEP=0; AC_SUBST([REPLACE_NANOSLEEP]) + REPLACE_STRFTIME=0; AC_SUBST([REPLACE_STRFTIME]) + REPLACE_TIME=0; AC_SUBST([REPLACE_TIME]) + REPLACE_TIMEGM=0; AC_SUBST([REPLACE_TIMEGM]) + REPLACE_TIMESPEC_GET=0; AC_SUBST([REPLACE_TIMESPEC_GET]) + REPLACE_TIMESPEC_GETRES=0; AC_SUBST([REPLACE_TIMESPEC_GETRES]) + REPLACE_TZSET=0; AC_SUBST([REPLACE_TZSET]) ]) diff --git a/gl/m4/time_r.m4 b/gl/m4/time_r.m4 index adce438..3675390 100644 --- a/gl/m4/time_r.m4 +++ b/gl/m4/time_r.m4 @@ -1,10 +1,12 @@ -dnl Reentrant time functions: localtime_r, gmtime_r. - -dnl Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc. +# time_r.m4 +# serial 1 +dnl Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl Reentrant time functions: localtime_r, gmtime_r. + dnl Written by Paul Eggert. AC_DEFUN([gl_TIME_R], @@ -57,9 +59,7 @@ AC_DEFUN([gl_TIME_R], [gl_cv_time_r_posix=yes], [gl_cv_time_r_posix=no]) ]) - if test $gl_cv_time_r_posix = yes; then - REPLACE_LOCALTIME_R=0 - else + if test $gl_cv_time_r_posix != yes; then REPLACE_LOCALTIME_R=1 fi else diff --git a/gl/m4/timegm.m4 b/gl/m4/timegm.m4 index 6079f1a..c1ff267 100644 --- a/gl/m4/timegm.m4 +++ b/gl/m4/timegm.m4 @@ -1,5 +1,6 @@ -# timegm.m4 serial 13 -dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc. +# timegm.m4 +# serial 16 +dnl Copyright (C) 2003, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -8,8 +9,7 @@ AC_DEFUN([gl_FUNC_TIMEGM], [ AC_REQUIRE([gl_TIME_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MKTIME_WORKS]) - REPLACE_TIMEGM=0 - AC_CHECK_FUNCS_ONCE([timegm]) + gl_CHECK_FUNCS_ANDROID([timegm], [[#include ]]) if test $ac_cv_func_timegm = yes; then if test "$gl_cv_func_working_mktime" != yes; then # Assume that timegm is buggy if mktime is. @@ -17,6 +17,9 @@ AC_DEFUN([gl_FUNC_TIMEGM], fi else HAVE_TIMEGM=0 + case "$gl_cv_onwards_func_timegm" in + future*) REPLACE_TIMEGM=1 ;; + esac fi ]) diff --git a/gl/m4/ungetc.m4 b/gl/m4/ungetc.m4 index 8977a34..42f7ec3 100644 --- a/gl/m4/ungetc.m4 +++ b/gl/m4/ungetc.m4 @@ -1,5 +1,6 @@ -# ungetc.m4 serial 10 -dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. +# ungetc.m4 +# serial 12 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -42,16 +43,16 @@ AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS], ]])], [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no], [case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_ungetc_works="guessing yes" ;; - # Guess yes on musl systems. - *-musl*) gl_cv_func_ungetc_works="guessing yes" ;; - # Guess yes on bionic systems. - *-android*) gl_cv_func_ungetc_works="guessing yes" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_ungetc_works="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_ungetc_works="$gl_cross_guess_normal" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_ungetc_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_ungetc_works="guessing yes" ;; + # Guess yes on bionic systems. + *-android*) gl_cv_func_ungetc_works="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_ungetc_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_ungetc_works="$gl_cross_guess_normal" ;; esac ]) ]) diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4 index f438402..81d1b9f 100644 --- a/gl/m4/unistd_h.m4 +++ b/gl/m4/unistd_h.m4 @@ -1,5 +1,6 @@ -# unistd_h.m4 serial 90 -dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. +# unistd_h.m4 +# serial 95 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -225,6 +226,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE]) REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) + REPLACE_DUP3=0; AC_SUBST([REPLACE_DUP3]) REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL]) REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE]) REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP]) @@ -233,11 +235,14 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP]) REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE]) REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT]) + REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR]) REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) + REPLACE_FDATASYNC=0; AC_SUBST([REPLACE_FDATASYNC]) REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE]) + REPLACE_GETENTROPY=0; AC_SUBST([REPLACE_GETENTROPY]) REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) @@ -248,12 +253,14 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) + REPLACE_PIPE2=0; AC_SUBST([REPLACE_PIPE2]) REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) REPLACE_READ=0; AC_SUBST([REPLACE_READ]) REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT]) REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) + REPLACE_SETHOSTNAME=0; AC_SUBST([REPLACE_SETHOSTNAME]) REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT]) diff --git a/gl/m4/unlocked-io.m4 b/gl/m4/unlocked-io.m4 index 407c0ba..e96cf5f 100644 --- a/gl/m4/unlocked-io.m4 +++ b/gl/m4/unlocked-io.m4 @@ -1,10 +1,9 @@ -# unlocked-io.m4 serial 16 - -# Copyright (C) 1998-2006, 2009-2023 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# unlocked-io.m4 +# serial 16 +dnl Copyright (C) 1998-2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. dnl From Jim Meyering. dnl diff --git a/gl/m4/vararrays.m4 b/gl/m4/vararrays.m4 index fd6230c..9211f69 100644 --- a/gl/m4/vararrays.m4 +++ b/gl/m4/vararrays.m4 @@ -1,13 +1,13 @@ -# Check for variable-length arrays. - +# vararrays.m4 # serial 6 +dnl Copyright (C) 2001, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -# From Paul Eggert +# Check for variable-length arrays. -# Copyright (C) 2001, 2009-2023 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +# From Paul Eggert m4_version_prereq([2.70], [], [ diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4 index 6361c84..1ea2055 100644 --- a/gl/m4/vasnprintf.m4 +++ b/gl/m4/vasnprintf.m4 @@ -1,5 +1,6 @@ -# vasnprintf.m4 serial 38 -dnl Copyright (C) 2002-2004, 2006-2023 Free Software Foundation, Inc. +# vasnprintf.m4 +# serial 52 +dnl Copyright (C) 2002-2004, 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -29,6 +30,15 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF], gl_PREREQ_ASNPRINTF ]) +AC_DEFUN([gl_FUNC_VASNWPRINTF], +[ + AC_LIBOBJ([printf-args]) + gl_PREREQ_PRINTF_ARGS + gl_PREREQ_PRINTF_PARSE + gl_PREREQ_VASNWPRINTF + gl_PREREQ_ASNPRINTF +]) + # Prerequisites of lib/printf-args.h, lib/printf-args.c. AC_DEFUN([gl_PREREQ_PRINTF_ARGS], [ @@ -37,6 +47,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS], ]) # Prerequisites of lib/printf-parse.h, lib/printf-parse.c. +# Prerequisites of lib/wprintf-parse.h, lib/wprintf-parse.c. AC_DEFUN([gl_PREREQ_PRINTF_PARSE], [ AC_REQUIRE([gl_FEATURES_H]) @@ -50,19 +61,13 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE], AC_REQUIRE([gt_AC_TYPE_INTMAX_T]) ]) -# Prerequisites of lib/vasnprintf.c. +# Prerequisites of lib/vasnprintf.c if !WIDE_CHAR_VERSION. AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], [ - AC_REQUIRE([AC_FUNC_ALLOCA]) - AC_REQUIRE([gt_TYPE_WCHAR_T]) - AC_REQUIRE([gt_TYPE_WINT_T]) - AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) + AC_CHECK_FUNCS([snprintf strnlen wcrtomb]) dnl Use the _snprintf function only if it is declared (because on NetBSD it dnl is defined as a weak alias of snprintf; we prefer to use the latter). AC_CHECK_DECLS([_snprintf], , , [[#include ]]) - dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization - dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE. - AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION]) dnl We can avoid a lot of code by assuming that snprintf's return value dnl conforms to ISO C99. So check that. AC_REQUIRE([gl_SNPRINTF_RETVAL_C99]) @@ -84,6 +89,108 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], terminated.]) ;; esac + gl_PREREQ_VASNXPRINTF +]) + +# Prerequisites of lib/vasnwprintf.c. +AC_DEFUN_ONCE([gl_PREREQ_VASNWPRINTF], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([swprintf wcsnlen mbrtowc]) + AC_CHECK_DECLS([_snwprintf], , , [[#include ]]) + AC_CHECK_DECLS([wcsnlen], , , [[#include ]]) + gl_SWPRINTF_WORKS + case "$gl_cv_func_swprintf_works" in + *yes) + AC_DEFINE([HAVE_WORKING_SWPRINTF], [1], + [Define if the swprintf function works correctly when it produces output + that contains null wide characters.]) + ;; + esac + gl_MBRTOWC_C_LOCALE + case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in + *yes) + AC_CACHE_CHECK([whether swprintf in the C locale is free of encoding errors], + [gl_cv_func_swprintf_C_locale_sans_EILSEQ], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#ifndef __USE_MINGW_ANSI_STDIO +# define __USE_MINGW_ANSI_STDIO 1 +#endif +#include +#include +int main() +{ + int result = 0; + { /* This test fails on glibc 2.35, musl libc 1.2.4, FreeBSD 13.2, NetBSD 9.3, + OpenBSD 7.2, Cygwin 2.9.0. + Reported at . */ + wchar_t buf[12]; + int ret = swprintf (buf, 12, L"%c", '\377'); + if (ret < 0) + result |= 1; + } + return result; +}]])], + [gl_cv_func_swprintf_C_locale_sans_EILSEQ=yes], + [gl_cv_func_swprintf_C_locale_sans_EILSEQ=no], + [case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_swprintf_C_locale_sans_EILSEQ="guessing yes";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_C_locale_sans_EILSEQ="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_C_locale_sans_EILSEQ="$gl_cross_guess_normal";; + esac + ]) + ]) + ;; + esac + if case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in + *yes) false ;; + *) true ;; + esac \ + || case "$gl_cv_func_swprintf_C_locale_sans_EILSEQ" in + *yes) false ;; + *) true ;; + esac; then + AC_DEFINE([NEED_WPRINTF_DIRECTIVE_C], [1], + [Define if the vasnwprintf implementation needs special code for + the 'c' directive.]) + fi + gl_SWPRINTF_DIRECTIVE_LA + case "$gl_cv_func_swprintf_directive_la" in + *yes) ;; + *) + AC_DEFINE([NEED_WPRINTF_DIRECTIVE_LA], [1], + [Define if the vasnwprintf implementation needs special code for + the 'a' directive with 'long double' arguments.]) + ;; + esac + gl_SWPRINTF_DIRECTIVE_LC + case "$gl_cv_func_swprintf_directive_lc" in + *yes) ;; + *) + AC_DEFINE([NEED_WPRINTF_DIRECTIVE_LC], [1], + [Define if the vasnwprintf implementation needs special code for + the 'lc' directive.]) + ;; + esac + gl_MUSL_LIBC + gl_PREREQ_VASNXPRINTF +]) + +# Common prerequisites of lib/vasnprintf.c and lib/vasnwprintf.c. +AC_DEFUN_ONCE([gl_PREREQ_VASNXPRINTF], +[ + AC_REQUIRE([AC_FUNC_ALLOCA]) + AC_REQUIRE([gt_TYPE_WCHAR_T]) + AC_REQUIRE([gt_TYPE_WINT_T]) + AC_CHECK_FUNCS([wcslen]) + dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization + dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE. + AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION]) ]) # Extra prerequisites of lib/vasnprintf.c for supporting 'long double' @@ -152,7 +259,22 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A], AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1], [Define if the vasnprintf implementation needs special code for the 'a' and 'A' directives.]) - AC_CHECK_FUNCS([nl_langinfo]) + gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include ]]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the 'b' directive. +AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_B], +[ + AC_REQUIRE([gl_PRINTF_DIRECTIVE_B]) + case "$gl_cv_func_printf_directive_b" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_DIRECTIVE_B], [1], + [Define if the vasnprintf implementation needs special code for + the 'b' directive.]) ;; esac ]) @@ -187,6 +309,21 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS], esac ]) +# Extra prerequisites of lib/vasnprintf.c for supporting the 'lc' directive. +AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LC], +[ + AC_REQUIRE([gl_PRINTF_DIRECTIVE_LC]) + case "$gl_cv_func_printf_directive_lc" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_DIRECTIVE_LC], [1], + [Define if the vasnprintf implementation needs special code for + the 'lc' directive.]) + ;; + esac +]) + # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING], [ @@ -232,6 +369,22 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO], esac ]) +# Extra prerequisites of lib/vasnprintf.c for supporting the # flag with a +# zero precision and a zero value in the 'x' and 'X' directives. +AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ALT_PRECISION_ZERO], +[ + AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO]) + case "$gl_cv_func_printf_flag_alt_precision_zero" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_FLAG_ALT_PRECISION_ZERO], [1], + [Define if the vasnprintf implementation needs special code for the + # flag with a zero precision and a zero value in the 'x' and 'X' directives.]) + ;; + esac +]) + # Extra prerequisites of lib/vasnprintf.c for supporting large precisions. AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION], [ @@ -276,23 +429,53 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM], ]) # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance. -AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS], +AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS], [ AC_REQUIRE([gl_PREREQ_VASNPRINTF]) gl_PREREQ_VASNPRINTF_LONG_DOUBLE gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE gl_PREREQ_VASNPRINTF_DIRECTIVE_A + gl_PREREQ_VASNPRINTF_DIRECTIVE_B gl_PREREQ_VASNPRINTF_DIRECTIVE_F gl_PREREQ_VASNPRINTF_DIRECTIVE_LS + gl_PREREQ_VASNPRINTF_DIRECTIVE_LC gl_PREREQ_VASNPRINTF_FLAG_GROUPING gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST gl_PREREQ_VASNPRINTF_FLAG_ZERO + gl_PREREQ_VASNPRINTF_FLAG_ALT_PRECISION_ZERO gl_PREREQ_VASNPRINTF_PRECISION gl_PREREQ_VASNPRINTF_ENOMEM ]) +# Extra prerequisites of lib/vasnprintf.c for supporting the 'B' directive. +AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_UPPERCASE_B], +[ + AC_REQUIRE([gl_PRINTF_DIRECTIVE_UPPERCASE_B]) + case "$gl_cv_func_printf_directive_uppercase_b" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_DIRECTIVE_UPPERCASE_B], [1], + [Define if the vasnprintf implementation needs special code for + the 'B' directive.]) + ;; + esac +]) + +# Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance +# and GNU compatibility. +AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS], +[ + gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS + AC_DEFINE([SUPPORT_GNU_PRINTF_DIRECTIVES], [1], + [Define if the vasnprintf implementation should support GNU compatible + printf directives.]) + gl_PREREQ_VASNPRINTF_DIRECTIVE_UPPERCASE_B +]) + # Prerequisites of lib/asnprintf.c. +# Prerequisites of lib/asnwprintf.c. AC_DEFUN([gl_PREREQ_ASNPRINTF], [ ]) diff --git a/gl/m4/vasprintf.m4 b/gl/m4/vasprintf.m4 index 6e6156a..73f7b80 100644 --- a/gl/m4/vasprintf.m4 +++ b/gl/m4/vasprintf.m4 @@ -1,5 +1,6 @@ -# vasprintf.m4 serial 6 -dnl Copyright (C) 2002-2003, 2006-2007, 2009-2023 Free Software Foundation, +# vasprintf.m4 +# serial 6 +dnl Copyright (C) 2002-2003, 2006-2007, 2009-2024 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/gl/m4/visibility.m4 b/gl/m4/visibility.m4 index f0468e8..ecf0968 100644 --- a/gl/m4/visibility.m4 +++ b/gl/m4/visibility.m4 @@ -1,5 +1,6 @@ -# visibility.m4 serial 8 -dnl Copyright (C) 2005, 2008, 2010-2023 Free Software Foundation, Inc. +# visibility.m4 +# serial 9 +dnl Copyright (C) 2005, 2008, 2010-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -31,18 +32,18 @@ AC_DEFUN([gl_VISIBILITY], dnl user has put into $CC $CFLAGS $CPPFLAGS. AC_CACHE_CHECK([whether the -Werror option is usable], [gl_cv_cc_vis_werror], - [gl_save_CFLAGS="$CFLAGS" + [gl_saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Werror" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[]], [[]])], [gl_cv_cc_vis_werror=yes], [gl_cv_cc_vis_werror=no]) - CFLAGS="$gl_save_CFLAGS" + CFLAGS="$gl_saved_CFLAGS" ]) dnl Now check whether visibility declarations are supported. AC_CACHE_CHECK([for simple visibility declarations], [gl_cv_cc_visibility], - [gl_save_CFLAGS="$CFLAGS" + [gl_saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" dnl We use the option -Werror and a function dummyfunc, because on some dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning @@ -68,7 +69,7 @@ AC_DEFUN([gl_VISIBILITY], [[]])], [gl_cv_cc_visibility=yes], [gl_cv_cc_visibility=no]) - CFLAGS="$gl_save_CFLAGS" + CFLAGS="$gl_saved_CFLAGS" ]) if test $gl_cv_cc_visibility = yes; then CFLAG_VISIBILITY="-fvisibility=hidden" diff --git a/gl/m4/vsnprintf.m4 b/gl/m4/vsnprintf.m4 index 7fbb11c..9f321f3 100644 --- a/gl/m4/vsnprintf.m4 +++ b/gl/m4/vsnprintf.m4 @@ -1,5 +1,6 @@ -# vsnprintf.m4 serial 7 -dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc. +# vsnprintf.m4 +# serial 7 +dnl Copyright (C) 2002-2004, 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4 index 10649c5..6c8c76b 100644 --- a/gl/m4/warn-on-use.m4 +++ b/gl/m4/warn-on-use.m4 @@ -1,5 +1,6 @@ -# warn-on-use.m4 serial 10 -dnl Copyright (C) 2010-2023 Free Software Foundation, Inc. +# warn-on-use.m4 +# serial 11 +dnl Copyright (C) 2010-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -36,7 +37,7 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE], dnl clang (e.g. strndup), reference ac_compile_for_check_decl instead dnl of ac_compile. If, for whatever reason, the override of AC_PROG_CC dnl in zzgnulib.m4 is inactive, use the original ac_compile. - ac_save_ac_compile="$ac_compile" + ac_saved_ac_compile="$ac_compile" if test -n "$ac_compile_for_check_decl"; then ac_compile="$ac_compile_for_check_decl" fi @@ -46,7 +47,7 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE], [[#undef $gl_func (void) $gl_func;]])], [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])]) - ac_compile="$ac_save_ac_compile" + ac_compile="$ac_saved_ac_compile" AS_VAR_IF([gl_Symbol], [yes], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) dnl Shortcut for an AC_CHECK_DECL invocation that may come later: diff --git a/gl/m4/wchar_h.m4 b/gl/m4/wchar_h.m4 index 8ec6619..995bdc6 100644 --- a/gl/m4/wchar_h.m4 +++ b/gl/m4/wchar_h.m4 @@ -1,13 +1,13 @@ -dnl A placeholder for ISO C99 , for platforms that have issues. - -dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. +# wchar_h.m4 +# serial 64 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -dnl Written by Eric Blake. +dnl A placeholder for ISO C99 , for platforms that have issues. -# wchar_h.m4 serial 55 +dnl Written by Eric Blake. AC_DEFUN_ONCE([gl_WCHAR_H], [ @@ -86,8 +86,8 @@ AC_DEFUN([gl_WCHAR_H_INLINE_OK], dnl z/OS when using the XPLINK object format (due to duplicate dnl CSECT names). Instead, temporarily redefine $ac_compile so dnl that the object file has the latter name from the start. - save_ac_compile="$ac_compile" - ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest1/` + saved_ac_compile="$ac_compile" + ac_compile=`echo "$saved_ac_compile" | sed s/conftest/conftest1/` if echo '#include "conftest.c"' >conftest1.c \ && AC_TRY_EVAL([ac_compile]); then AC_LANG_CONFTEST([ @@ -97,7 +97,7 @@ AC_DEFUN([gl_WCHAR_H_INLINE_OK], int zero (void) { return 0; } ]])]) dnl See note above about renaming object files. - ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest2/` + ac_compile=`echo "$saved_ac_compile" | sed s/conftest/conftest2/` if echo '#include "conftest.c"' >conftest2.c \ && AC_TRY_EVAL([ac_compile]); then if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then @@ -107,7 +107,7 @@ AC_DEFUN([gl_WCHAR_H_INLINE_OK], fi fi fi - ac_compile="$save_ac_compile" + ac_compile="$saved_ac_compile" rm -f conftest[12].c conftest[12].$ac_objext conftest$ac_exeext ;; esac @@ -147,6 +147,7 @@ AC_DEFUN([gl_WCHAR_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BTOWC]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOB]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSINIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSZERO]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOWC]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRLEN]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRTOWCS]) @@ -185,6 +186,7 @@ AC_DEFUN([gl_WCHAR_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSTOK]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSWIDTH]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSFTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WGETCWD]) dnl Support Microsoft deprecated alias function names by default. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WCSDUP], [1]) ]) @@ -253,5 +255,10 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS], REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH]) REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME]) + REPLACE_WCSCMP=0; AC_SUBST([REPLACE_WCSCMP]) + REPLACE_WCSNCMP=0; AC_SUBST([REPLACE_WCSNCMP]) + REPLACE_WCSSTR=0; AC_SUBST([REPLACE_WCSSTR]) REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK]) + REPLACE_WMEMCMP=0; AC_SUBST([REPLACE_WMEMCMP]) + REPLACE_WMEMPCPY=0; AC_SUBST([REPLACE_WMEMPCPY]) ]) diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4 index 50bde08..968832c 100644 --- a/gl/m4/wchar_t.m4 +++ b/gl/m4/wchar_t.m4 @@ -1,5 +1,6 @@ -# wchar_t.m4 serial 4 (gettext-0.18.2) -dnl Copyright (C) 2002-2003, 2008-2023 Free Software Foundation, Inc. +# wchar_t.m4 +# serial 4 (gettext-0.18.2) +dnl Copyright (C) 2002-2003, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/wcrtomb.m4 b/gl/m4/wcrtomb.m4 index d51b36e..35dff6f 100644 --- a/gl/m4/wcrtomb.m4 +++ b/gl/m4/wcrtomb.m4 @@ -1,5 +1,6 @@ -# wcrtomb.m4 serial 17 -dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. +# wcrtomb.m4 +# serial 19 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -82,9 +83,11 @@ int main () changequote(,)dnl case "$host_os" in # Guess no on AIX 4, OSF/1, Solaris, native Windows. - aix4* | osf* | solaris* | mingw*) gl_cv_func_wcrtomb_retval="guessing no" ;; + aix4* | osf* | solaris* | mingw* | windows*) + gl_cv_func_wcrtomb_retval="guessing no" ;; # Guess yes otherwise. - *) gl_cv_func_wcrtomb_retval="guessing yes" ;; + *) + gl_cv_func_wcrtomb_retval="guessing yes" ;; esac changequote([,])dnl if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then @@ -97,12 +100,14 @@ changequote([,])dnl int main () { int result = 0; - if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) + if (strcmp ("$LOCALE_FR", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR") != NULL) { if (wcrtomb (NULL, 0, NULL) != 1) result |= 1; } - if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) { if (wcrtomb (NULL, 0, NULL) != 1) result |= 2; @@ -113,12 +118,14 @@ int main () result |= 2; } } - if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) + if (strcmp ("$LOCALE_JA", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_JA") != NULL) { if (wcrtomb (NULL, 0, NULL) != 1) result |= 4; } - if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + if (strcmp ("$LOCALE_ZH_CN", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) { if (wcrtomb (NULL, 0, NULL) != 1) result |= 8; diff --git a/gl/m4/wctype.m4 b/gl/m4/wctype.m4 new file mode 100644 index 0000000..e5d7074 --- /dev/null +++ b/gl/m4/wctype.m4 @@ -0,0 +1,52 @@ +# wctype.m4 +# serial 6 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_FUNC_WCTYPE], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + HAVE_WCTYPE=$HAVE_WCTYPE_T + if test $HAVE_WCTYPE = 1; then + AC_CACHE_CHECK([whether wctype supports the "blank" and "punct" character classes], + [gl_cv_func_wctype_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + #include + #include + int main () + { + /* This test fails on mingw. */ + if (wctype ("blank") == (wctype_t)0) + return 1; + /* This test fails on MSVC 14. */ + if ((! iswctype ('\t', wctype ("blank"))) != (! iswblank ('\t'))) + return 2; + /* This test fails on Android 11. */ + if ((! iswctype ('\`', wctype ("punct"))) != (! ispunct ('\`'))) + return 4; + return 0; + } + ]])], + [gl_cv_func_wctype_works=yes], [gl_cv_func_wctype_works=no], + [case "$host_os" in + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_wctype_works="guessing no" ;; + # Guess no on Android. + android*) gl_cv_func_wctype_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_wctype_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_wctype_works" in + *yes) ;; + *) REPLACE_WCTYPE=1 ;; + esac + fi +]) diff --git a/gl/m4/wctype_h.m4 b/gl/m4/wctype_h.m4 index 6856a73..a3b07c2 100644 --- a/gl/m4/wctype_h.m4 +++ b/gl/m4/wctype_h.m4 @@ -1,8 +1,9 @@ -# wctype_h.m4 serial 30 +# wctype_h.m4 +# serial 33 dnl A placeholder for ISO C99 , for platforms that lack it. -dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -178,6 +179,7 @@ AC_DEFUN([gl_WCTYPE_H_REQUIRE_DEFAULTS], m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS], [ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWBLANK]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWDIGIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWPUNCT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWXDIGIT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTYPE]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWCTYPE]) @@ -196,5 +198,8 @@ AC_DEFUN([gl_WCTYPE_H_DEFAULTS], HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T]) REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK]) REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT]) + REPLACE_ISWPUNCT=0; AC_SUBST([REPLACE_ISWPUNCT]) REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT]) + REPLACE_WCTRANS=0; AC_SUBST([REPLACE_WCTRANS]) + REPLACE_WCTYPE=0; AC_SUBST([REPLACE_WCTYPE]) ]) diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4 index dfd743b..883fac2 100644 --- a/gl/m4/wint_t.m4 +++ b/gl/m4/wint_t.m4 @@ -1,5 +1,6 @@ -# wint_t.m4 serial 11 -dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc. +# wint_t.m4 +# serial 11 +dnl Copyright (C) 2003, 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/xalloc.m4 b/gl/m4/xalloc.m4 index fc56f59..d44d0f0 100644 --- a/gl/m4/xalloc.m4 +++ b/gl/m4/xalloc.m4 @@ -1,5 +1,6 @@ -# xalloc.m4 serial 18 -dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc. +# xalloc.m4 +# serial 18 +dnl Copyright (C) 2002-2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/xsize.m4 b/gl/m4/xsize.m4 index 649db9c..e578497 100644 --- a/gl/m4/xsize.m4 +++ b/gl/m4/xsize.m4 @@ -1,5 +1,6 @@ -# xsize.m4 serial 5 -dnl Copyright (C) 2003-2004, 2008-2023 Free Software Foundation, Inc. +# xsize.m4 +# serial 5 +dnl Copyright (C) 2003-2004, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/m4/zzgnulib.m4 b/gl/m4/zzgnulib.m4 index 362102b..710fba4 100644 --- a/gl/m4/zzgnulib.m4 +++ b/gl/m4/zzgnulib.m4 @@ -1,5 +1,6 @@ -# zzgnulib.m4 serial 1 -dnl Copyright (C) 2020-2023 Free Software Foundation, Inc. +# zzgnulib.m4 +# serial 1 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/gl/malloc.c b/gl/malloc.c index 3ade35c..2a7867a 100644 --- a/gl/malloc.c +++ b/gl/malloc.c @@ -1,6 +1,6 @@ /* malloc() function that is glibc compatible. - Copyright (C) 1997-1998, 2006-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 1997-1998, 2006-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/malloc/dynarray-skeleton.c b/gl/malloc/dynarray-skeleton.c index 580c278..a95241a 100644 --- a/gl/malloc/dynarray-skeleton.c +++ b/gl/malloc/dynarray-skeleton.c @@ -1,5 +1,5 @@ /* Type-safe arrays which grow dynamically. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/gl/malloc/dynarray.h b/gl/malloc/dynarray.h index a9a3b08..3163e27 100644 --- a/gl/malloc/dynarray.h +++ b/gl/malloc/dynarray.h @@ -1,5 +1,5 @@ /* Type-safe arrays which grow dynamically. Shared definitions. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/gl/malloc/dynarray_at_failure.c b/gl/malloc/dynarray_at_failure.c index ebc9310..95e34e7 100644 --- a/gl/malloc/dynarray_at_failure.c +++ b/gl/malloc/dynarray_at_failure.c @@ -1,5 +1,5 @@ /* Report an dynamic array index out of bounds condition. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/gl/malloc/dynarray_emplace_enlarge.c b/gl/malloc/dynarray_emplace_enlarge.c index 7da5393..7bdba15 100644 --- a/gl/malloc/dynarray_emplace_enlarge.c +++ b/gl/malloc/dynarray_emplace_enlarge.c @@ -1,5 +1,5 @@ /* Increase the size of a dynamic array in preparation of an emplace operation. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -56,7 +56,7 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list, } size_t new_size; - if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size)) + if (ckd_mul (&new_size, new_allocated, element_size)) return false; void *new_array; if (list->array == scratch) diff --git a/gl/malloc/dynarray_finalize.c b/gl/malloc/dynarray_finalize.c index 673595a..52764f7 100644 --- a/gl/malloc/dynarray_finalize.c +++ b/gl/malloc/dynarray_finalize.c @@ -1,5 +1,5 @@ /* Copy the dynamically-allocated area to an explicitly-sized heap allocation. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/gl/malloc/dynarray_resize.c b/gl/malloc/dynarray_resize.c index 7ecd4de..7323f8e 100644 --- a/gl/malloc/dynarray_resize.c +++ b/gl/malloc/dynarray_resize.c @@ -1,5 +1,5 @@ /* Increase the size of a dynamic array. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -42,7 +42,7 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size, over-allocation here. */ size_t new_size_bytes; - if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes)) + if (ckd_mul (&new_size_bytes, size, element_size)) { /* Overflow. */ __set_errno (ENOMEM); diff --git a/gl/malloc/dynarray_resize_clear.c b/gl/malloc/dynarray_resize_clear.c index bb23c52..aa17f74 100644 --- a/gl/malloc/dynarray_resize_clear.c +++ b/gl/malloc/dynarray_resize_clear.c @@ -1,5 +1,5 @@ /* Increase the size of a dynamic array and clear the new part. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/gl/malloca.c b/gl/malloca.c index f055b1e..e75c72d 100644 --- a/gl/malloca.c +++ b/gl/malloca.c @@ -1,5 +1,5 @@ /* Safe automatic memory allocation. - Copyright (C) 2003, 2006-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2003, 2018. This file is free software: you can redistribute it and/or modify @@ -22,6 +22,9 @@ #include "malloca.h" #include +#if defined __CHERI_PURE_CAPABILITY__ +# include +#endif #include "idx.h" @@ -36,10 +39,15 @@ allocation. - NULL comes from a failed heap allocation. */ +#if defined __CHERI_PURE_CAPABILITY__ +/* Type for holding the original malloc() result. */ +typedef uintptr_t small_t; +#else /* Type for holding very small pointer differences. */ typedef unsigned char small_t; /* Verify that it is wide enough. */ static_assert (2 * sa_alignment_max - 1 <= (small_t) -1); +#endif void * mmalloca (size_t n) @@ -56,20 +64,28 @@ mmalloca (size_t n) if (mem != NULL) { - uintptr_t umem = (uintptr_t)mem, umemplus; + uintptr_t umem = (uintptr_t) mem; /* The ckd_add avoids signed integer overflow on theoretical platforms where UINTPTR_MAX <= INT_MAX. */ + uintptr_t umemplus; ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1); - idx_t offset = ((umemplus & ~alignment2_mask) + idx_t offset = (umemplus - umemplus % (2 * sa_alignment_max) + sa_alignment_max - umem); - void *vp = mem + offset; - small_t *p = vp; + void *p = mem + offset; /* Here p >= mem + sizeof (small_t), and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1 hence p + n <= mem + nplus. So, the memory range [p, p+n) lies in the allocated memory range [mem, mem + nplus). */ - p[-1] = offset; + small_t *sp = p; +# if defined __CHERI_PURE_CAPABILITY__ + sp[-1] = umem; + p = (char *) cheri_bounds_set ((char *) p - sizeof (small_t), + sizeof (small_t) + n) + + sizeof (small_t); +# else + sp[-1] = offset; +# endif /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */ return p; } @@ -90,15 +106,22 @@ void freea (void *p) { /* Check argument. */ - if ((uintptr_t) p & (sa_alignment_max - 1)) + uintptr_t u = (uintptr_t) p; + if (u & (sa_alignment_max - 1)) { /* p was not the result of a malloca() call. Invalid argument. */ abort (); } /* Determine whether p was a non-NULL pointer returned by mmalloca(). */ - if ((uintptr_t) p & sa_alignment_max) + if (u & sa_alignment_max) { - void *mem = (char *) p - ((small_t *) p)[-1]; + char *cp = p; + small_t *sp = p; +# if defined __CHERI_PURE_CAPABILITY__ + void *mem = sp[-1]; +# else + void *mem = cp - sp[-1]; +# endif free (mem); } } diff --git a/gl/malloca.h b/gl/malloca.h index 325c727..c520842 100644 --- a/gl/malloca.h +++ b/gl/malloca.h @@ -1,5 +1,5 @@ /* Safe automatic memory allocation. - Copyright (C) 2003-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2003-2007, 2009-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This file is free software: you can redistribute it and/or modify @@ -18,10 +18,19 @@ #ifndef _MALLOCA_H #define _MALLOCA_H +/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_DEALLOC, + _GL_ATTRIBUTE_MALLOC, HAVE_ALLOCA. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include #include #include +#if defined __CHERI_PURE_CAPABILITY__ +# include +#endif #include "xalloc-oversized.h" @@ -62,12 +71,24 @@ extern void freea (void *p); memory allocated on the stack, that must be freed using freea() before the function returns. Upon failure, it returns NULL. */ #if HAVE_ALLOCA -# define malloca(N) \ - ((N) < 4032 - (2 * sa_alignment_max - 1) \ - ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ - + (2 * sa_alignment_max - 1)) \ - & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ - : mmalloca (N)) +# if defined __CHERI_PURE_CAPABILITY__ +# define malloca(N) \ + ((N) < 4032 - (2 * sa_alignment_max - 1) \ + ? cheri_bounds_set ((void *) (((uintptr_t) \ + (char *) \ + alloca ((N) + 2 * sa_alignment_max - 1) \ + + (2 * sa_alignment_max - 1)) \ + & ~(uintptr_t)(2 * sa_alignment_max - 1)), \ + (N)) \ + : mmalloca (N)) +# else +# define malloca(N) \ + ((N) < 4032 - (2 * sa_alignment_max - 1) \ + ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ + + (2 * sa_alignment_max - 1)) \ + & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ + : mmalloca (N)) +# endif #else # define malloca(N) \ mmalloca (N) diff --git a/gl/math.c b/gl/math.c index 67cabbc..78da4d4 100644 --- a/gl/math.c +++ b/gl/math.c @@ -1,6 +1,6 @@ /* Inline functions for . - Copyright (C) 2012-2023 Free Software Foundation, Inc. + Copyright (C) 2012-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,5 +18,5 @@ #include #define _GL_MATH_INLINE _GL_EXTERN_INLINE -#include "math.h" +#include typedef int dummy; diff --git a/gl/math.in.h b/gl/math.in.h index f3d58af..96d0da4 100644 --- a/gl/math.in.h +++ b/gl/math.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 2002-2003, 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -15,6 +15,11 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ +/* On Android, in C++ mode, when /usr/include/c++/v1/math.h is being included + and /usr/include/math.h has not yet been included, skip this file, since it + would lead to many syntax errors. */ +#if !(defined __ANDROID__ && defined _LIBCPP_MATH_H && !defined INFINITY) + #ifndef _@GUARD_PREFIX@_MATH_H #if __GNUC__ >= 3 @@ -43,14 +48,17 @@ #ifndef _@GUARD_PREFIX@_MATH_H #define _@GUARD_PREFIX@_MATH_H +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_CONST, + GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* On OpenVMS, NAN, INFINITY, and HUGEVAL macros are defined in . */ #if defined __VMS && ! defined NAN # include #endif -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_MATH_INLINE # define _GL_MATH_INLINE _GL_INLINE @@ -1427,6 +1435,29 @@ _GL_WARN_ON_USE (ldexpf, "ldexpf is unportable - " #endif /* Return x * 2^exp. */ +#if @GNULIB_LDEXP@ +# if @REPLACE_LDEXP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ldexp +# define ldexp rpl_ldexp +# endif +_GL_FUNCDECL_RPL (ldexp, double, (double x, int exp)); +_GL_CXXALIAS_RPL (ldexp, double, (double x, int exp)); +# else +/* Assume ldexp is always declared. */ +_GL_CXXALIAS_SYS (ldexp, double, (double x, int exp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (ldexp, double, (double x, int exp)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ldexp +/* Assume ldexp is always declared. */ +_GL_WARN_ON_USE (ldexp, "ldexp is unportable - " + "use gnulib module ldexp for portability"); +#endif + +/* Return x * 2^exp. */ #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ldexpl @@ -1691,7 +1722,9 @@ _GL_FUNCDECL_SYS (log2f, float, (float x)); # endif _GL_CXXALIAS_SYS (log2f, float, (float x)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (log2f); +# endif #elif defined GNULIB_POSIXCHECK # undef log2f # if HAVE_RAW_DECL_LOG2F @@ -2512,16 +2545,22 @@ _GL_WARN_REAL_FLOATING_DECL (isinf); #if @GNULIB_ISNANF@ /* Test for NaN for 'float' numbers. */ # if @HAVE_ISNANF@ +# if defined __sun || defined __sgi +/* Solaris and IRIX have isnanf() and declare it in . We cannot + define isnanf as a macro, because that would conflict with . */ +_GL_EXTERN_C int isnanf (float x); +# else /* The original included above provides a declaration of isnan macro or (older) isnanf function. */ -# if (__GNUC__ >= 4) || (__clang_major__ >= 4) +# if (__GNUC__ >= 4) || (__clang_major__ >= 4) /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. GCC >= 4.0 also provides __builtin_isnanf, but clang doesn't. */ -# undef isnanf -# define isnanf(x) __builtin_isnan ((float)(x)) -# elif defined isnan -# undef isnanf -# define isnanf(x) isnan ((float)(x)) +# undef isnanf +# define isnanf(x) __builtin_isnan ((float)(x)) +# elif defined isnan +# undef isnanf +# define isnanf(x) isnan ((float)(x)) +# endif # endif # else /* Test whether X is a NaN. */ @@ -2536,15 +2575,21 @@ _GL_EXTERN_C int isnanf (float x); This function is a gnulib extension, unlike isnan() which applied only to 'double' numbers earlier but now is a type-generic macro. */ # if @HAVE_ISNAND@ +# if defined __sun || defined __sgi +/* Solaris and IRIX have isnand() and declare it in . We cannot + define isnand as a macro, because that would conflict with . */ +_GL_EXTERN_C int isnand (double x); +# else /* The original included above provides a declaration of isnan macro. */ -# if (__GNUC__ >= 4) || (__clang_major__ >= 4) +# if (__GNUC__ >= 4) || (__clang_major__ >= 4) /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. */ -# undef isnand -# define isnand(x) __builtin_isnan ((double)(x)) -# else -# undef isnand -# define isnand(x) isnan ((double)(x)) +# undef isnand +# define isnand(x) __builtin_isnan ((double)(x)) +# else +# undef isnand +# define isnand(x) isnan ((double)(x)) +# endif # endif # else /* Test whether X is a NaN. */ @@ -2617,12 +2662,17 @@ _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; # if defined isnan || defined GNULIB_NAMESPACE _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) # undef isnan -# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__ && __clang_major__ < 12) || (defined __FreeBSD__ && (__clang_major__ < 7 || __clang_major__ >= 11)) || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__))) +# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__ && __clang_major__ != 12) || (defined __FreeBSD__ && (__clang_major__ < 7 || __clang_major__ >= 11)) || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__))) /* This platform's possibly defines isnan through a set of inline functions. */ _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool) # define isnan rpl_isnan # define GNULIB_NAMESPACE_LACKS_ISNAN 1 +# elif __clang_major__ >= 14 + /* Neither of the two possible _GL_MATH_CXX_REAL_FLOATING_DECL_2 invocations + works. Inline functions are already present in /usr/include/c++/v1/math.h, + which comes from LLVM. */ +# define GNULIB_NAMESPACE_LACKS_ISNAN 1 # else _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool) # endif @@ -2657,12 +2707,13 @@ _GL_WARN_REAL_FLOATING_DECL (isnan); _GL_EXTERN_C int gl_signbitf (float arg); _GL_EXTERN_C int gl_signbitd (double arg); _GL_EXTERN_C int gl_signbitl (long double arg); -# if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__ +# if __GNUC__ >= 2 || defined __clang__ # define _GL_NUM_UINT_WORDS(type) \ ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf # define gl_signbitf_OPTIMIZED_MACRO # define gl_signbitf(arg) \ + __extension__ \ ({ union { float _value; \ unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \ } _m; \ @@ -2673,6 +2724,7 @@ _GL_EXTERN_C int gl_signbitl (long double arg); # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd # define gl_signbitd_OPTIMIZED_MACRO # define gl_signbitd(arg) \ + __extension__ \ ({ union { double _value; \ unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \ } _m; \ @@ -2683,6 +2735,7 @@ _GL_EXTERN_C int gl_signbitl (long double arg); # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl # define gl_signbitl_OPTIMIZED_MACRO # define gl_signbitl(arg) \ + __extension__ \ ({ union { long double _value; \ unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \ } _m; \ @@ -2720,8 +2773,323 @@ _GL_WARN_REAL_FLOATING_DECL (signbit); # endif #endif + +#if @GNULIB_GETPAYLOADF@ +# if @REPLACE_GETPAYLOADF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getpayloadf +# define getpayloadf rpl_getpayloadf +# endif +_GL_FUNCDECL_RPL (getpayloadf, float, (const float *)); +_GL_CXXALIAS_RPL (getpayloadf, float, (const float *)); +# else +# if !@HAVE_GETPAYLOADF@ +_GL_FUNCDECL_SYS (getpayloadf, float, (const float *)); +# endif +_GL_CXXALIAS_SYS (getpayloadf, float, (const float *)); +# endif +_GL_CXXALIASWARN (getpayloadf); +#elif defined GNULIB_POSIXCHECK +# undef getpayloadf +# if HAVE_RAW_DECL_GETPAYLOADF +_GL_WARN_ON_USE (getpayloadf, "getpayloadf is unportable - " + "use gnulib module getpayloadf for portability"); +# endif +#endif + +#if @GNULIB_GETPAYLOAD@ +# if @REPLACE_GETPAYLOAD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getpayload +# define getpayload rpl_getpayload +# endif +_GL_FUNCDECL_RPL (getpayload, double, (const double *)); +_GL_CXXALIAS_RPL (getpayload, double, (const double *)); +# else +# if !@HAVE_GETPAYLOAD@ +_GL_FUNCDECL_SYS (getpayload, double, (const double *)); +# endif +_GL_CXXALIAS_SYS (getpayload, double, (const double *)); +# endif +_GL_CXXALIASWARN (getpayload); +#elif defined GNULIB_POSIXCHECK +# undef getpayload +# if HAVE_RAW_DECL_GETPAYLOAD +_GL_WARN_ON_USE (getpayload, "getpayload is unportable - " + "use gnulib module getpayload for portability"); +# endif +#endif + +#if @GNULIB_GETPAYLOADL@ +# if @REPLACE_GETPAYLOADL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getpayloadl +# define getpayloadl rpl_getpayloadl +# endif +_GL_FUNCDECL_RPL (getpayloadl, long double, (const long double *)); +_GL_CXXALIAS_RPL (getpayloadl, long double, (const long double *)); +# else +# if !@HAVE_GETPAYLOADL@ +_GL_FUNCDECL_SYS (getpayloadl, long double, (const long double *)); +# endif +_GL_CXXALIAS_SYS (getpayloadl, long double, (const long double *)); +# endif +_GL_CXXALIASWARN (getpayloadl); +#elif defined GNULIB_POSIXCHECK +# undef getpayloadl +# if HAVE_RAW_DECL_GETPAYLOADL +_GL_WARN_ON_USE (getpayloadl, "getpayloadl is unportable - " + "use gnulib module getpayloadl for portability"); +# endif +#endif + + +#if @GNULIB_SETPAYLOADF@ +# if !@HAVE_SETPAYLOADF@ +_GL_FUNCDECL_SYS (setpayloadf, int, (float *, float)); +# endif +_GL_CXXALIAS_SYS (setpayloadf, int, (float *, float)); +_GL_CXXALIASWARN (setpayloadf); +#elif defined GNULIB_POSIXCHECK +# undef setpayloadf +# if HAVE_RAW_DECL_SETPAYLOADF +_GL_WARN_ON_USE (setpayloadf, "setpayloadf is unportable - " + "use gnulib module setpayloadf for portability"); +# endif +#endif + +#if @GNULIB_SETPAYLOAD@ +# if !@HAVE_SETPAYLOAD@ +_GL_FUNCDECL_SYS (setpayload, int, (double *, double)); +# endif +_GL_CXXALIAS_SYS (setpayload, int, (double *, double)); +_GL_CXXALIASWARN (setpayload); +#elif defined GNULIB_POSIXCHECK +# undef setpayload +# if HAVE_RAW_DECL_SETPAYLOAD +_GL_WARN_ON_USE (setpayload, "setpayload is unportable - " + "use gnulib module setpayload for portability"); +# endif +#endif + +#if @GNULIB_SETPAYLOADL@ +# if !@HAVE_SETPAYLOADL@ +_GL_FUNCDECL_SYS (setpayloadl, int, (long double *, long double)); +# endif +_GL_CXXALIAS_SYS (setpayloadl, int, (long double *, long double)); +_GL_CXXALIASWARN (setpayloadl); +#elif defined GNULIB_POSIXCHECK +# undef setpayloadl +# if HAVE_RAW_DECL_SETPAYLOADL +_GL_WARN_ON_USE (setpayloadl, "setpayloadl is unportable - " + "use gnulib module setpayloadl for portability"); +# endif +#endif + + +#if @GNULIB_SETPAYLOADSIGF@ +# if !@HAVE_SETPAYLOADSIGF@ +_GL_FUNCDECL_SYS (setpayloadsigf, int, (float *, float)); +# endif +_GL_CXXALIAS_SYS (setpayloadsigf, int, (float *, float)); +_GL_CXXALIASWARN (setpayloadsigf); +#elif defined GNULIB_POSIXCHECK +# undef setpayloadsigf +# if HAVE_RAW_DECL_SETPAYLOADSIGF +_GL_WARN_ON_USE (setpayloadsigf, "setpayloadsigf is unportable - " + "use gnulib module setpayloadsigf for portability"); +# endif +#endif + +#if @GNULIB_SETPAYLOADSIG@ +# if !@HAVE_SETPAYLOADSIG@ +_GL_FUNCDECL_SYS (setpayloadsig, int, (double *, double)); +# endif +_GL_CXXALIAS_SYS (setpayloadsig, int, (double *, double)); +_GL_CXXALIASWARN (setpayloadsig); +#elif defined GNULIB_POSIXCHECK +# undef setpayloadsig +# if HAVE_RAW_DECL_SETPAYLOADSIG +_GL_WARN_ON_USE (setpayloadsig, "setpayloadsig is unportable - " + "use gnulib module setpayloadsig for portability"); +# endif +#endif + +#if @GNULIB_SETPAYLOADSIGL@ +# if !@HAVE_SETPAYLOADSIGL@ +_GL_FUNCDECL_SYS (setpayloadsigl, int, (long double *, long double)); +# endif +_GL_CXXALIAS_SYS (setpayloadsigl, int, (long double *, long double)); +_GL_CXXALIASWARN (setpayloadsigl); +#elif defined GNULIB_POSIXCHECK +# undef setpayloadsigl +# if HAVE_RAW_DECL_SETPAYLOADSIGL +_GL_WARN_ON_USE (setpayloadsigl, "setpayloadsigl is unportable - " + "use gnulib module setpayloadsigl for portability"); +# endif +#endif + + +#if @GNULIB_TOTALORDERF@ +# if @REPLACE_TOTALORDERF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef totalorderf +# define totalorderf rpl_totalorderf +# endif +_GL_FUNCDECL_RPL (totalorderf, int, (float const *, float const *)); +_GL_CXXALIAS_RPL (totalorderf, int, (float const *, float const *)); +# else +# if !@HAVE_TOTALORDERF@ +_GL_FUNCDECL_SYS (totalorderf, int, (float const *, float const *)); +# endif +_GL_CXXALIAS_SYS (totalorderf, int, (float const *, float const *)); +# endif +_GL_CXXALIASWARN (totalorderf); +#elif defined GNULIB_POSIXCHECK +# undef totalorderf +# if HAVE_RAW_DECL_TOTALORDERF +_GL_WARN_ON_USE (totalorderf, "totalorderf is unportable - " + "use gnulib module totalorderf for portability"); +# endif +#endif + +#if @GNULIB_TOTALORDER@ +# if @REPLACE_TOTALORDER@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef totalorder +# define totalorder rpl_totalorder +# endif +_GL_FUNCDECL_RPL (totalorder, int, (double const *, double const *)); +_GL_CXXALIAS_RPL (totalorder, int, (double const *, double const *)); +# else +# if !@HAVE_TOTALORDER@ +_GL_FUNCDECL_SYS (totalorder, int, (double const *, double const *)); +# endif +_GL_CXXALIAS_SYS (totalorder, int, (double const *, double const *)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (totalorder, int, (double const *, double const *)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef totalorder +# if HAVE_RAW_DECL_TOTALORDER +_GL_WARN_ON_USE (totalorder, "totalorder is unportable - " + "use gnulib module totalorder for portability"); +# endif +#endif + +#if @GNULIB_TOTALORDERL@ +# if @REPLACE_TOTALORDERL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef totalorderl +# define totalorderl rpl_totalorderl +# endif +_GL_FUNCDECL_RPL (totalorderl, int, + (long double const *, long double const *)); +_GL_CXXALIAS_RPL (totalorderl, int, + (long double const *, long double const *)); +# else +# if !@HAVE_TOTALORDERL@ +_GL_FUNCDECL_SYS (totalorderl, int, + (long double const *, long double const *)); +# endif +_GL_CXXALIAS_SYS (totalorderl, int, + (long double const *, long double const *)); +# endif +_GL_CXXALIASWARN (totalorderl); +#elif defined GNULIB_POSIXCHECK +# undef totalorderl +# if HAVE_RAW_DECL_TOTALORDERL +_GL_WARN_ON_USE (totalorderl, "totalorderl is unportable - " + "use gnulib module totalorderl for portability"); +# endif +#endif + + +#if @GNULIB_TOTALORDERMAGF@ +# if @REPLACE_TOTALORDERMAGF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef totalordermagf +# define totalordermagf rpl_totalordermagf +# endif +_GL_FUNCDECL_RPL (totalordermagf, int, (float const *, float const *)); +_GL_CXXALIAS_RPL (totalordermagf, int, (float const *, float const *)); +# else +# if !@HAVE_TOTALORDERMAGF@ +_GL_FUNCDECL_SYS (totalordermagf, int, (float const *, float const *)); +# endif +_GL_CXXALIAS_SYS (totalordermagf, int, (float const *, float const *)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (totalordermagf, int, (float const *, float const *)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef totalordermagf +# if HAVE_RAW_DECL_TOTALORDERMAGF +_GL_WARN_ON_USE (totalordermagf, "totalordermagf is unportable - " + "use gnulib module totalordermagf for portability"); +# endif +#endif + +#if @GNULIB_TOTALORDERMAG@ +# if @REPLACE_TOTALORDERMAG@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef totalordermag +# define totalordermag rpl_totalordermag +# endif +_GL_FUNCDECL_RPL (totalordermag, int, (double const *, double const *)); +_GL_CXXALIAS_RPL (totalordermag, int, (double const *, double const *)); +# else +# if !@HAVE_TOTALORDERMAG@ +_GL_FUNCDECL_SYS (totalordermag, int, (double const *, double const *)); +# endif +_GL_CXXALIAS_SYS (totalordermag, int, (double const *, double const *)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (totalordermag, int, (double const *, double const *)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef totalordermag +# if HAVE_RAW_DECL_TOTALORDERMAG +_GL_WARN_ON_USE (totalordermag, "totalordermag is unportable - " + "use gnulib module totalordermag for portability"); +# endif +#endif + +#if @GNULIB_TOTALORDERMAGL@ +# if @REPLACE_TOTALORDERMAGL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef totalordermagl +# define totalordermagl rpl_totalordermagl +# endif +_GL_FUNCDECL_RPL (totalordermagl, int, + (long double const *, long double const *)); +_GL_CXXALIAS_RPL (totalordermagl, int, + (long double const *, long double const *)); +# else +# if !@HAVE_TOTALORDERMAGL@ +_GL_FUNCDECL_SYS (totalordermagl, int, + (long double const *, long double const *)); +# endif +_GL_CXXALIAS_SYS (totalordermagl, int, + (long double const *, long double const *)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (totalordermagl, int, + (long double const *, long double const *)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef totalordermagl +# if HAVE_RAW_DECL_TOTALORDERMAGL +_GL_WARN_ON_USE (totalordermagl, "totalordermagl is unportable - " + "use gnulib module totalordermagl for portability"); +# endif +#endif + + _GL_INLINE_HEADER_END #endif /* _@GUARD_PREFIX@_MATH_H */ #endif /* _GL_INCLUDING_MATH_H */ #endif /* _@GUARD_PREFIX@_MATH_H */ +#endif diff --git a/gl/mbrtowc-impl-utf8.h b/gl/mbrtowc-impl-utf8.h index 4fdd65d..3a3ba13 100644 --- a/gl/mbrtowc-impl-utf8.h +++ b/gl/mbrtowc-impl-utf8.h @@ -1,5 +1,5 @@ /* Convert multibyte character to wide character. - Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/mbrtowc-impl.h b/gl/mbrtowc-impl.h index e9c04ed..963631c 100644 --- a/gl/mbrtowc-impl.h +++ b/gl/mbrtowc-impl.h @@ -1,5 +1,5 @@ /* Convert multibyte character to wide character. - Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/mbrtowc.c b/gl/mbrtowc.c index c1a689a..8a1646d 100644 --- a/gl/mbrtowc.c +++ b/gl/mbrtowc.c @@ -1,5 +1,5 @@ /* Convert multibyte character to wide character. - Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2005-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This file is free software: you can redistribute it and/or modify @@ -28,7 +28,11 @@ # include # include -# if defined _WIN32 && !defined __CYGWIN__ +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ + +# elif defined _WIN32 && !defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN /* avoid including junk */ # include diff --git a/gl/mbsinit.c b/gl/mbsinit.c index 6e60079..d1b8475 100644 --- a/gl/mbsinit.c +++ b/gl/mbsinit.c @@ -1,5 +1,5 @@ /* Test for initial conversion state. - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This file is free software: you can redistribute it and/or modify @@ -36,7 +36,7 @@ buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. See mbrtowc.c. - In wc -> mb direction, mbstate_t contains no information. In other - words, it is always in the initial state. */ + words, it is always in an initial state. */ static_assert (sizeof (mbstate_t) >= 4); diff --git a/gl/mbszero.c b/gl/mbszero.c new file mode 100644 index 0000000..25af284 --- /dev/null +++ b/gl/mbszero.c @@ -0,0 +1,23 @@ +/* Put an mbstate_t into an initial conversion state. + Copyright (C) 2023-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#define IN_MBSZERO +/* Specification and implementation. */ +#include diff --git a/gl/mbtowc-impl.h b/gl/mbtowc-impl.h index 39b977b..92efb4a 100644 --- a/gl/mbtowc-impl.h +++ b/gl/mbtowc-impl.h @@ -1,5 +1,5 @@ /* Convert multibyte character to wide character. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2011. This file is free software: you can redistribute it and/or modify @@ -30,7 +30,7 @@ mbtowc (wchar_t *pwc, const char *s, size_t n) wchar_t wc; size_t result; - memset (&state, 0, sizeof (mbstate_t)); + mbszero (&state); result = mbrtowc (&wc, s, n, &state); if (result == (size_t)-1 || result == (size_t)-2) { diff --git a/gl/mbtowc-lock.c b/gl/mbtowc-lock.c index 6ca6e10..9001c5a 100644 --- a/gl/mbtowc-lock.c +++ b/gl/mbtowc-lock.c @@ -1,5 +1,5 @@ /* Return the internal lock used by mbrtowc and mbrtoc32. - Copyright (C) 2019-2023 Free Software Foundation, Inc. + Copyright (C) 2019-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,9 +18,10 @@ #include +/* The option '--disable-threads' explicitly requests no locking. */ /* When it is known that the gl_get_mbtowc_lock function is defined by a dependency library, it should not be defined here. */ -#if OMIT_MBTOWC_LOCK +#if AVOID_ANY_THREADS || OMIT_MBTOWC_LOCK /* This declaration is solely to ensure that after preprocessing this file is never empty. */ @@ -37,14 +38,14 @@ typedef int dummy; /* Macro for exporting a symbol (function, not variable) defined in this file, when compiled into a shared library. */ -# ifndef DLL_EXPORTED +# ifndef SHLIB_EXPORTED # if HAVE_VISIBILITY /* Override the effect of the compiler option '-fvisibility=hidden'. */ -# define DLL_EXPORTED __attribute__((__visibility__("default"))) +# define SHLIB_EXPORTED __attribute__((__visibility__("default"))) # elif defined _WIN32 || defined __CYGWIN__ -# define DLL_EXPORTED __declspec(dllexport) +# define SHLIB_EXPORTED __declspec(dllexport) # else -# define DLL_EXPORTED +# define SHLIB_EXPORTED # endif # endif @@ -59,7 +60,7 @@ typedef int dummy; because the latter is not guaranteed to be a stable ABI in the future. */ /* Make sure the function gets exported from DLLs. */ -DLL_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void); +SHLIB_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void); static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT; static CRITICAL_SECTION lock; @@ -96,7 +97,7 @@ gl_get_mbtowc_lock (void) static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* Make sure the function gets exported from shared libraries. */ -DLL_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void); +SHLIB_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void); /* Returns the internal lock used by mbrtowc and mbrtoc32. */ pthread_mutex_t * @@ -123,7 +124,7 @@ atomic_init (void) } /* Make sure the function gets exported from shared libraries. */ -DLL_EXPORTED mtx_t *gl_get_mbtowc_lock (void); +SHLIB_EXPORTED mtx_t *gl_get_mbtowc_lock (void); /* Returns the internal lock used by mbrtowc and mbrtoc32. */ mtx_t * diff --git a/gl/mbtowc-lock.h b/gl/mbtowc-lock.h index 2dc22ac..10f7dc7 100644 --- a/gl/mbtowc-lock.h +++ b/gl/mbtowc-lock.h @@ -1,5 +1,5 @@ /* Use the internal lock used by mbrtowc and mbrtoc32. - Copyright (C) 2019-2023 Free Software Foundation, Inc. + Copyright (C) 2019-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -21,7 +21,7 @@ static inline int mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m) { - /* Put the hidden internal state of mbtowc into its initial state. + /* Put the hidden internal state of mbtowc into an initial state. This is needed at least with glibc, uClibc, and MSVC CRT. See . */ mbtowc (NULL, NULL, 0); @@ -32,7 +32,7 @@ mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m) /* Prohibit renaming this symbol. */ #undef gl_get_mbtowc_lock -#if GNULIB_MBRTOWC_SINGLE_THREAD +#if AVOID_ANY_THREADS || GNULIB_MBRTOWC_SINGLE_THREAD /* All uses of this function are in a single thread. No locking needed. */ diff --git a/gl/mbtowc.c b/gl/mbtowc.c index 8d9b06d..31a2d63 100644 --- a/gl/mbtowc.c +++ b/gl/mbtowc.c @@ -1,5 +1,5 @@ /* Convert multibyte character to wide character. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2011. This file is free software: you can redistribute it and/or modify diff --git a/gl/memchr.c b/gl/memchr.c index 8e95579..67687a8 100644 --- a/gl/memchr.c +++ b/gl/memchr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2023 +/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2024 Free Software Foundation, Inc. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), diff --git a/gl/memchr.valgrind b/gl/memchr.valgrind index 97690f2..0295d7e 100644 --- a/gl/memchr.valgrind +++ b/gl/memchr.valgrind @@ -1,6 +1,6 @@ # Suppress a valgrind message about use of uninitialized memory in memchr(). -# Copyright (C) 2009-2023 Free Software Foundation, Inc. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. # # This file is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as diff --git a/gl/minmax.h b/gl/minmax.h index 1fbfc66..f3df58b 100644 --- a/gl/minmax.h +++ b/gl/minmax.h @@ -1,5 +1,5 @@ /* MIN, MAX macros. - Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2023 Free Software + Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -23,6 +23,11 @@ MIN, MAX macro redefinitions on some systems; the workaround is to #include this file as the last one among the #include list. */ +/* This file uses HAVE_MINMAX_IN_LIMITS_H, HAVE_MINMAX_IN_SYS_PARAM_H. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Before we define the following symbols we get the file since otherwise we get redefinitions on some systems if is included after this file. Likewise for . diff --git a/gl/mktime-internal.h b/gl/mktime-internal.h index 709c36b..0693aaf 100644 --- a/gl/mktime-internal.h +++ b/gl/mktime-internal.h @@ -1,5 +1,5 @@ /* Internals of mktime and related functions - Copyright 2016-2023 Free Software Foundation, Inc. + Copyright 2016-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Eggert . diff --git a/gl/mktime.c b/gl/mktime.c index 94a4320..c704f41 100644 --- a/gl/mktime.c +++ b/gl/mktime.c @@ -1,5 +1,5 @@ /* Convert a 'struct tm' to a time_t value. - Copyright (C) 1993-2023 Free Software Foundation, Inc. + Copyright (C) 1993-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Eggert . @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -379,7 +380,7 @@ __mktime_internal (struct tm *tp, /* Invert CONVERT by probing. First assume the same offset as last time. */ - INT_SUBTRACT_WRAPV (0, off, &negative_offset_guess); + ckd_sub (&negative_offset_guess, 0, off); long_int t0 = ydhms_diff (year, yday, hour, min, sec, EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, negative_offset_guess); @@ -465,7 +466,7 @@ __mktime_internal (struct tm *tp, for (direction = -1; direction <= 1; direction += 2) { long_int ot; - if (! INT_ADD_WRAPV (t, delta * direction, &ot)) + if (! ckd_add (&ot, t, delta * direction)) { struct tm otm; if (! ranged_convert (convert, &ot, &otm)) @@ -503,8 +504,8 @@ __mktime_internal (struct tm *tp, /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS. This is just a heuristic to speed up the next mktime call, and correctness is unaffected if integer overflow occurs here. */ - INT_SUBTRACT_WRAPV (t, t0, offset); - INT_SUBTRACT_WRAPV (*offset, negative_offset_guess, offset); + ckd_sub (offset, t, t0); + ckd_sub (offset, *offset, negative_offset_guess); if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) { @@ -513,7 +514,7 @@ __mktime_internal (struct tm *tp, long_int sec_adjustment = sec == 0 && tm.tm_sec == 60; sec_adjustment -= sec; sec_adjustment += sec_requested; - if (INT_ADD_WRAPV (t, sec_adjustment, &t) + if (ckd_add (&t, t, sec_adjustment) || ! (mktime_min <= t && t <= mktime_max)) { __set_errno (EOVERFLOW); diff --git a/gl/mountlist.c b/gl/mountlist.c index 6d38481..06300d6 100644 --- a/gl/mountlist.c +++ b/gl/mountlist.c @@ -1,6 +1,6 @@ /* mountlist.c -- return a list of mounted file systems - Copyright (C) 1991-1992, 1997-2023 Free Software Foundation, Inc. + Copyright (C) 1991-1992, 1997-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -154,11 +154,18 @@ /* The results of opendir() in this file are not used with dirfd and fchdir, therefore save some unnecessary work in fchdir.c. */ -#ifdef GNULIB_defined_opendir +#ifdef GNULIB_defined_DIR +# undef DIR # undef opendir -#endif -#ifdef GNULIB_defined_closedir # undef closedir +# undef readdir +#else +# ifdef GNULIB_defined_opendir +# undef opendir +# endif +# ifdef GNULIB_defined_closedir +# undef closedir +# endif #endif #define ME_DUMMY_0(Fs_name, Fs_type) \ @@ -185,11 +192,11 @@ we grant an exception to any with "bind" in its list of mount options. I.e., those are *not* dummy entries. */ #ifdef MOUNTED_GETMNTENT1 -# define ME_DUMMY(Fs_name, Fs_type, Bind) \ - (ME_DUMMY_0 (Fs_name, Fs_type) \ +# define ME_DUMMY(Fs_name, Fs_type, Bind) \ + (ME_DUMMY_0 (Fs_name, Fs_type) \ || (strcmp (Fs_type, "none") == 0 && !Bind)) #else -# define ME_DUMMY(Fs_name, Fs_type) \ +# define ME_DUMMY(Fs_name, Fs_type) \ (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0) #endif diff --git a/gl/mountlist.h b/gl/mountlist.h index aed7f88..9728e38 100644 --- a/gl/mountlist.h +++ b/gl/mountlist.h @@ -1,6 +1,6 @@ /* mountlist.h -- declarations for list of mounted file systems - Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2023 Free Software + Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -17,9 +17,19 @@ along with this program. If not, see . */ #ifndef MOUNTLIST_H_ -# define MOUNTLIST_H_ +#define MOUNTLIST_H_ + +/* This file uses _GL_ATTRIBUTE_MALLOC. */ +#if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif -# include /* A mount table entry. */ struct mount_entry @@ -40,4 +50,9 @@ struct mount_entry *read_file_system_list (bool need_fs_type) _GL_ATTRIBUTE_MALLOC; void free_mount_entry (struct mount_entry *entry); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/gl/msvc-inval.c b/gl/msvc-inval.c index c5149a8..da3fc86 100644 --- a/gl/msvc-inval.c +++ b/gl/msvc-inval.c @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/msvc-inval.h b/gl/msvc-inval.h index ed00461..7aee6e5 100644 --- a/gl/msvc-inval.h +++ b/gl/msvc-inval.h @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -52,6 +52,11 @@ AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING]) */ +/* This file uses HAVE_MSVC_INVALID_PARAMETER_HANDLER. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #define DEFAULT_HANDLING 0 #define HAIRY_LIBRARY_HANDLING 1 #define SANE_LIBRARY_HANDLING 2 diff --git a/gl/msvc-nothrow.c b/gl/msvc-nothrow.c index f729fe6..06b35a6 100644 --- a/gl/msvc-nothrow.c +++ b/gl/msvc-nothrow.c @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/msvc-nothrow.h b/gl/msvc-nothrow.h index 82d3f6a..121773d 100644 --- a/gl/msvc-nothrow.h +++ b/gl/msvc-nothrow.h @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -25,11 +25,20 @@ This file defines wrappers that turn such an invalid parameter notification into an error code. */ +/* This file uses HAVE_MSVC_INVALID_PARAMETER_HANDLER. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #if defined _WIN32 && ! defined __CYGWIN__ /* Get original declaration of _get_osfhandle. */ # include +# ifdef __cplusplus +extern "C" { +# endif + # if HAVE_MSVC_INVALID_PARAMETER_HANDLER /* Override _get_osfhandle. */ @@ -38,6 +47,10 @@ extern intptr_t _gl_nothrow_get_osfhandle (int fd); # endif +# ifdef __cplusplus +} +# endif + #endif #endif /* _MSVC_NOTHROW_H */ diff --git a/gl/netdb.in.h b/gl/netdb.in.h index 9549cd7..43409b2 100644 --- a/gl/netdb.in.h +++ b/gl/netdb.in.h @@ -1,5 +1,5 @@ /* Provide a netdb.h header file for systems lacking it (read: MinGW). - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. Written by Simon Josefsson. This file is free software: you can redistribute it and/or modify @@ -36,6 +36,11 @@ #ifndef _@GUARD_PREFIX@_NETDB_H #define _@GUARD_PREFIX@_NETDB_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Get definitions such as 'socklen_t' on IRIX 6.5 and OSF/1 4.0 and 'struct hostent' on MinGW. */ #include diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h index f88923a..4e9f6f2 100644 --- a/gl/netinet_in.in.h +++ b/gl/netinet_in.in.h @@ -1,5 +1,5 @@ /* Substitute for . - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/nl_langinfo-lock.c b/gl/nl_langinfo-lock.c index e5cdcd3..5a248ed 100644 --- a/gl/nl_langinfo-lock.c +++ b/gl/nl_langinfo-lock.c @@ -1,5 +1,5 @@ /* Return the internal lock used by nl_langinfo. - Copyright (C) 2019-2023 Free Software Foundation, Inc. + Copyright (C) 2019-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,9 +18,10 @@ #include +/* The option '--disable-threads' explicitly requests no locking. */ /* When it is known that the gl_get_nl_langinfo_lock function is defined by a dependency library, it should not be defined here. */ -#if OMIT_NL_LANGINFO_LOCK +#if AVOID_ANY_THREADS || OMIT_NL_LANGINFO_LOCK /* This declaration is solely to ensure that after preprocessing this file is never empty. */ @@ -37,14 +38,14 @@ typedef int dummy; /* Macro for exporting a symbol (function, not variable) defined in this file, when compiled into a shared library. */ -# ifndef DLL_EXPORTED +# ifndef SHLIB_EXPORTED # if HAVE_VISIBILITY /* Override the effect of the compiler option '-fvisibility=hidden'. */ -# define DLL_EXPORTED __attribute__((__visibility__("default"))) +# define SHLIB_EXPORTED __attribute__((__visibility__("default"))) # elif defined _WIN32 || defined __CYGWIN__ -# define DLL_EXPORTED __declspec(dllexport) +# define SHLIB_EXPORTED __declspec(dllexport) # else -# define DLL_EXPORTED +# define SHLIB_EXPORTED # endif # endif @@ -59,7 +60,7 @@ typedef int dummy; because the latter is not guaranteed to be a stable ABI in the future. */ /* Make sure the function gets exported from DLLs. */ -DLL_EXPORTED CRITICAL_SECTION *gl_get_nl_langinfo_lock (void); +SHLIB_EXPORTED CRITICAL_SECTION *gl_get_nl_langinfo_lock (void); static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT; static CRITICAL_SECTION lock; @@ -96,7 +97,7 @@ gl_get_nl_langinfo_lock (void) static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* Make sure the function gets exported from shared libraries. */ -DLL_EXPORTED pthread_mutex_t *gl_get_nl_langinfo_lock (void); +SHLIB_EXPORTED pthread_mutex_t *gl_get_nl_langinfo_lock (void); /* Returns the internal lock used by nl_langinfo. */ pthread_mutex_t * @@ -123,7 +124,7 @@ atomic_init (void) } /* Make sure the function gets exported from shared libraries. */ -DLL_EXPORTED mtx_t *gl_get_nl_langinfo_lock (void); +SHLIB_EXPORTED mtx_t *gl_get_nl_langinfo_lock (void); /* Returns the internal lock used by nl_langinfo. */ mtx_t * diff --git a/gl/nl_langinfo.c b/gl/nl_langinfo.c index 131166f..64ff93b 100644 --- a/gl/nl_langinfo.c +++ b/gl/nl_langinfo.c @@ -1,6 +1,6 @@ /* nl_langinfo() replacement: query locale dependent information. - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -30,7 +30,12 @@ #endif #if REPLACE_NL_LANGINFO && !NL_LANGINFO_MTSAFE -# if defined _WIN32 && !defined __CYGWIN__ + +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ + +# elif defined _WIN32 && !defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN /* avoid including junk */ # include @@ -51,6 +56,7 @@ # include # endif + #endif /* nl_langinfo() must be multithread-safe. To achieve this without using @@ -70,6 +76,8 @@ static char * ctype_codeset (void) { + /* This function is only used on platforms which don't have uselocale(). + Therefore we don't need to look at the per-thread locale first, here. */ static char result[2 + 10 + 1]; char buf[2 + 10 + 1]; char locale[SETLOCALE_NULL_MAX]; @@ -184,7 +192,12 @@ nl_langinfo_unlocked (nl_item item) /* Prohibit renaming this symbol. */ # undef gl_get_nl_langinfo_lock -# if defined _WIN32 && !defined __CYGWIN__ +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ +# define nl_langinfo_with_lock nl_langinfo_unlocked + +# elif defined _WIN32 && !defined __CYGWIN__ extern __declspec(dllimport) CRITICAL_SECTION *gl_get_nl_langinfo_lock (void); @@ -449,7 +462,7 @@ nl_langinfo (nl_item item) { static char const months[][sizeof "September"] = { "January", "February", "March", "April", "May", "June", "July", - "September", "October", "November", "December" + "August", "September", "October", "November", "December" }; case MON_1: case MON_2: @@ -513,7 +526,7 @@ nl_langinfo (nl_item item) static char result[12][30]; static char const abmonths[][sizeof "Jan"] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", - "Sep", "Oct", "Nov", "Dec" + "Aug", "Sep", "Oct", "Nov", "Dec" }; tmm.tm_mon = item - ABMON_1; if (!strftime (buf, sizeof result[0], "%b", &tmm)) diff --git a/gl/open.c b/gl/open.c index 7ec8fdc..e690c9e 100644 --- a/gl/open.c +++ b/gl/open.c @@ -1,5 +1,5 @@ /* Open a descriptor to a file. - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -38,9 +38,13 @@ orig_open (const char *filename, int flags, mode_t mode) } /* Specification. */ +#ifdef __osf__ /* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "fcntl.h" +# include "fcntl.h" +#else +# include +#endif #include "cloexec.h" diff --git a/gl/pathmax.h b/gl/pathmax.h index 0dd8f3b..d6512c6 100644 --- a/gl/pathmax.h +++ b/gl/pathmax.h @@ -1,5 +1,5 @@ /* Define PATH_MAX somehow. Requires sys/types.h. - Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2023 Free Software + Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -39,6 +39,11 @@ #endif */ +/* This file uses HAVE_SYS_PARAM_H. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + # include # include diff --git a/gl/printf-args.c b/gl/printf-args.c index 5e14f65..eb0d2cd 100644 --- a/gl/printf-args.c +++ b/gl/printf-args.c @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2023 Free Software + Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -29,6 +29,9 @@ # include "printf-args.h" #endif +/* Get INT_WIDTH. */ +#include + #ifdef STATIC STATIC #endif @@ -71,6 +74,102 @@ PRINTF_FETCHARGS (va_list args, arguments *a) case TYPE_ULONGLONGINT: ap->a.a_ulonglongint = va_arg (args, unsigned long long int); break; + case TYPE_INT8_T: + #if INT8_WIDTH < INT_WIDTH + ap->a.a_int8_t = va_arg (args, /* int8_t */ int); + #else + ap->a.a_int8_t = va_arg (args, int8_t); + #endif + break; + case TYPE_UINT8_T: + #if UINT8_WIDTH < INT_WIDTH + ap->a.a_uint8_t = va_arg (args, /* uint8_t */ int); + #else + ap->a.a_uint8_t = va_arg (args, uint8_t); + #endif + break; + case TYPE_INT16_T: + #if INT16_WIDTH < INT_WIDTH + ap->a.a_int16_t = va_arg (args, /* int16_t */ int); + #else + ap->a.a_int16_t = va_arg (args, int16_t); + #endif + break; + case TYPE_UINT16_T: + #if UINT16_WIDTH < INT_WIDTH + ap->a.a_uint16_t = va_arg (args, /* uint16_t */ int); + #else + ap->a.a_uint16_t = va_arg (args, uint16_t); + #endif + break; + case TYPE_INT32_T: + #if INT32_WIDTH < INT_WIDTH + ap->a.a_int32_t = va_arg (args, /* int32_t */ int); + #else + ap->a.a_int32_t = va_arg (args, int32_t); + #endif + break; + case TYPE_UINT32_T: + #if UINT32_WIDTH < INT_WIDTH + ap->a.a_uint32_t = va_arg (args, /* uint32_t */ int); + #else + ap->a.a_uint32_t = va_arg (args, uint32_t); + #endif + break; + case TYPE_INT64_T: + ap->a.a_int64_t = va_arg (args, int64_t); + break; + case TYPE_UINT64_T: + ap->a.a_uint64_t = va_arg (args, uint64_t); + break; + case TYPE_INT_FAST8_T: + #if INT_FAST8_WIDTH < INT_WIDTH + ap->a.a_int_fast8_t = va_arg (args, /* int_fast8_t */ int); + #else + ap->a.a_int_fast8_t = va_arg (args, int_fast8_t); + #endif + break; + case TYPE_UINT_FAST8_T: + #if UINT_FAST8_WIDTH < INT_WIDTH + ap->a.a_uint_fast8_t = va_arg (args, /* uint_fast8_t */ int); + #else + ap->a.a_uint_fast8_t = va_arg (args, uint_fast8_t); + #endif + break; + case TYPE_INT_FAST16_T: + #if INT_FAST16_WIDTH < INT_WIDTH + ap->a.a_int_fast16_t = va_arg (args, /* int_fast16_t */ int); + #else + ap->a.a_int_fast16_t = va_arg (args, int_fast16_t); + #endif + break; + case TYPE_UINT_FAST16_T: + #if UINT_FAST16_WIDTH < INT_WIDTH + ap->a.a_uint_fast16_t = va_arg (args, /* uint_fast16_t */ int); + #else + ap->a.a_uint_fast16_t = va_arg (args, uint_fast16_t); + #endif + break; + case TYPE_INT_FAST32_T: + #if INT_FAST32_WIDTH < INT_WIDTH + ap->a.a_int_fast32_t = va_arg (args, /* int_fast32_t */ int); + #else + ap->a.a_int_fast32_t = va_arg (args, int_fast32_t); + #endif + break; + case TYPE_UINT_FAST32_T: + #if UINT_FAST32_WIDTH < INT_WIDTH + ap->a.a_uint_fast32_t = va_arg (args, /* uint_fast32_t */ int); + #else + ap->a.a_uint_fast32_t = va_arg (args, uint_fast32_t); + #endif + break; + case TYPE_INT_FAST64_T: + ap->a.a_int_fast64_t = va_arg (args, int_fast64_t); + break; + case TYPE_UINT_FAST64_T: + ap->a.a_uint_fast64_t = va_arg (args, uint_fast64_t); + break; case TYPE_DOUBLE: ap->a.a_double = va_arg (args, double); break; @@ -136,6 +235,30 @@ PRINTF_FETCHARGS (va_list args, arguments *a) case TYPE_COUNT_LONGLONGINT_POINTER: ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); break; + case TYPE_COUNT_INT8_T_POINTER: + ap->a.a_count_int8_t_pointer = va_arg (args, int8_t *); + break; + case TYPE_COUNT_INT16_T_POINTER: + ap->a.a_count_int16_t_pointer = va_arg (args, int16_t *); + break; + case TYPE_COUNT_INT32_T_POINTER: + ap->a.a_count_int32_t_pointer = va_arg (args, int32_t *); + break; + case TYPE_COUNT_INT64_T_POINTER: + ap->a.a_count_int64_t_pointer = va_arg (args, int64_t *); + break; + case TYPE_COUNT_INT_FAST8_T_POINTER: + ap->a.a_count_int_fast8_t_pointer = va_arg (args, int_fast8_t *); + break; + case TYPE_COUNT_INT_FAST16_T_POINTER: + ap->a.a_count_int_fast16_t_pointer = va_arg (args, int_fast16_t *); + break; + case TYPE_COUNT_INT_FAST32_T_POINTER: + ap->a.a_count_int_fast32_t_pointer = va_arg (args, int_fast32_t *); + break; + case TYPE_COUNT_INT_FAST64_T_POINTER: + ap->a.a_count_int_fast64_t_pointer = va_arg (args, int_fast64_t *); + break; #if ENABLE_UNISTDIO /* The unistdio extensions. */ case TYPE_U8_STRING: diff --git a/gl/printf-args.h b/gl/printf-args.h index f303cb1..9b80bb3 100644 --- a/gl/printf-args.h +++ b/gl/printf-args.h @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2023 Free Software + Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -41,6 +41,9 @@ # include #endif +/* Get intN_t, uintN_t, intN_fast_t, uintN_fast_t. */ +#include + /* Get va_list. */ #include @@ -59,6 +62,26 @@ typedef enum TYPE_ULONGINT, TYPE_LONGLONGINT, TYPE_ULONGLONGINT, + /* According to ISO C 23 § 7.23.6.1, "all exact-width integer types", + "all minimum-width integer types", and "all fastest minimum-width integer + types" defined in should be supported. But for portability + between platforms, we support only those with N = 8, 16, 32, 64. */ + TYPE_INT8_T, + TYPE_UINT8_T, + TYPE_INT16_T, + TYPE_UINT16_T, + TYPE_INT32_T, + TYPE_UINT32_T, + TYPE_INT64_T, + TYPE_UINT64_T, + TYPE_INT_FAST8_T, + TYPE_UINT_FAST8_T, + TYPE_INT_FAST16_T, + TYPE_UINT_FAST16_T, + TYPE_INT_FAST32_T, + TYPE_UINT_FAST32_T, + TYPE_INT_FAST64_T, + TYPE_UINT_FAST64_T, TYPE_DOUBLE, TYPE_LONGDOUBLE, TYPE_CHAR, @@ -74,7 +97,15 @@ typedef enum TYPE_COUNT_SHORT_POINTER, TYPE_COUNT_INT_POINTER, TYPE_COUNT_LONGINT_POINTER, - TYPE_COUNT_LONGLONGINT_POINTER + TYPE_COUNT_LONGLONGINT_POINTER, + TYPE_COUNT_INT8_T_POINTER, + TYPE_COUNT_INT16_T_POINTER, + TYPE_COUNT_INT32_T_POINTER, + TYPE_COUNT_INT64_T_POINTER, + TYPE_COUNT_INT_FAST8_T_POINTER, + TYPE_COUNT_INT_FAST16_T_POINTER, + TYPE_COUNT_INT_FAST32_T_POINTER, + TYPE_COUNT_INT_FAST64_T_POINTER #if ENABLE_UNISTDIO /* The unistdio extensions. */ , TYPE_U8_STRING @@ -99,7 +130,23 @@ typedef struct unsigned long int a_ulongint; long long int a_longlongint; unsigned long long int a_ulonglongint; - float a_float; + int8_t a_int8_t; + uint8_t a_uint8_t; + int16_t a_int16_t; + uint16_t a_uint16_t; + int32_t a_int32_t; + uint32_t a_uint32_t; + int64_t a_int64_t; + uint64_t a_uint64_t; + int_fast8_t a_int_fast8_t; + uint_fast8_t a_uint_fast8_t; + int_fast16_t a_int_fast16_t; + uint_fast16_t a_uint_fast16_t; + int_fast32_t a_int_fast32_t; + uint_fast32_t a_uint_fast32_t; + int_fast64_t a_int_fast64_t; + uint_fast64_t a_uint_fast64_t; + float a_float; /* unused */ double a_double; long double a_longdouble; int a_char; @@ -116,6 +163,14 @@ typedef struct int * a_count_int_pointer; long int * a_count_longint_pointer; long long int * a_count_longlongint_pointer; + int8_t * a_count_int8_t_pointer; + int16_t * a_count_int16_t_pointer; + int32_t * a_count_int32_t_pointer; + int64_t * a_count_int64_t_pointer; + int_fast8_t * a_count_int_fast8_t_pointer; + int_fast16_t * a_count_int_fast16_t_pointer; + int_fast32_t * a_count_int_fast32_t_pointer; + int_fast64_t * a_count_int_fast64_t_pointer; #if ENABLE_UNISTDIO /* The unistdio extensions. */ const uint8_t * a_u8_string; diff --git a/gl/printf-parse.c b/gl/printf-parse.c index 3040749..a33e27a 100644 --- a/gl/printf-parse.c +++ b/gl/printf-parse.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003, 2006-2023 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2003, 2006-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -326,226 +326,320 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) arg_type type; /* Parse argument type/size specifiers. */ - { - int flags = 0; - - for (;;) - { - if (*cp == 'h') - { - flags |= (1 << (flags & 1)); - cp++; - } - else if (*cp == 'L') - { - flags |= 4; - cp++; - } - else if (*cp == 'l') - { - flags += 8; - cp++; - } - else if (*cp == 'j') - { - if (sizeof (intmax_t) > sizeof (long)) - { - /* intmax_t = long long */ - flags += 16; - } - else if (sizeof (intmax_t) > sizeof (int)) - { - /* intmax_t = long */ - flags += 8; - } - cp++; - } - else if (*cp == 'z' || *cp == 'Z') - { - /* 'z' is standardized in ISO C 99, but glibc uses 'Z' - because the warning facility in gcc-2.95.2 understands - only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ - if (sizeof (size_t) > sizeof (long)) - { - /* size_t = long long */ - flags += 16; - } - else if (sizeof (size_t) > sizeof (int)) - { - /* size_t = long */ - flags += 8; - } - cp++; - } - else if (*cp == 't') - { - if (sizeof (ptrdiff_t) > sizeof (long)) - { - /* ptrdiff_t = long long */ - flags += 16; - } - else if (sizeof (ptrdiff_t) > sizeof (int)) - { - /* ptrdiff_t = long */ - flags += 8; - } - cp++; - } + /* Relevant for the conversion characters d, i. */ + arg_type signed_type = TYPE_INT; + /* Relevant for the conversion characters b, o, u, x, X. */ + arg_type unsigned_type = TYPE_UINT; + /* Relevant for the conversion characters n. */ + arg_type pointer_type = TYPE_COUNT_INT_POINTER; + /* Relevant for the conversion characters a, A, e, E, f, F, g, G. */ + arg_type floatingpoint_type = TYPE_DOUBLE; + + if (*cp == 'h') + { + if (cp[1] == 'h') + { + signed_type = TYPE_SCHAR; + unsigned_type = TYPE_UCHAR; + pointer_type = TYPE_COUNT_SCHAR_POINTER; + cp += 2; + } + else + { + signed_type = TYPE_SHORT; + unsigned_type = TYPE_USHORT; + pointer_type = TYPE_COUNT_SHORT_POINTER; + cp++; + } + } + else if (*cp == 'l') + { + if (cp[1] == 'l') + { + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + cp += 2; + } + else + { + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + cp++; + } + } + else if (*cp == 'j') + { + if (sizeof (intmax_t) > sizeof (long)) + { + /* intmax_t = long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else if (sizeof (intmax_t) > sizeof (int)) + { + /* intmax_t = long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp++; + } + else if (*cp == 'z' || *cp == 'Z') + { + /* 'z' is standardized in ISO C 99, but glibc uses 'Z' + because the warning facility in gcc-2.95.2 understands + only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ + if (sizeof (size_t) > sizeof (long)) + { + /* size_t = unsigned long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else if (sizeof (size_t) > sizeof (int)) + { + /* size_t = unsigned long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp++; + } + else if (*cp == 't') + { + if (sizeof (ptrdiff_t) > sizeof (long)) + { + /* ptrdiff_t = long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else if (sizeof (ptrdiff_t) > sizeof (int)) + { + /* ptrdiff_t = long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp++; + } + else if (*cp == 'w') + { + /* wN and wfN are standardized in ISO C 23. */ + if (cp[1] == 'f') + { + if (cp[2] == '8') + { + signed_type = TYPE_INT_FAST8_T; + unsigned_type = TYPE_UINT_FAST8_T; + pointer_type = TYPE_COUNT_INT_FAST8_T_POINTER; + cp += 3; + } + else if (cp[2] == '1' && cp[3] == '6') + { + signed_type = TYPE_INT_FAST16_T; + unsigned_type = TYPE_UINT_FAST16_T; + pointer_type = TYPE_COUNT_INT_FAST16_T_POINTER; + cp += 4; + } + else if (cp[2] == '3' && cp[3] == '2') + { + signed_type = TYPE_INT_FAST32_T; + unsigned_type = TYPE_UINT_FAST32_T; + pointer_type = TYPE_COUNT_INT_FAST32_T_POINTER; + cp += 4; + } + else if (cp[2] == '6' && cp[3] == '4') + { + signed_type = TYPE_INT_FAST64_T; + unsigned_type = TYPE_UINT_FAST64_T; + pointer_type = TYPE_COUNT_INT_FAST64_T_POINTER; + cp += 4; + } + } + else + { + if (cp[1] == '8') + { + signed_type = TYPE_INT8_T; + unsigned_type = TYPE_UINT8_T; + pointer_type = TYPE_COUNT_INT8_T_POINTER; + cp += 2; + } + else if (cp[1] == '1' && cp[2] == '6') + { + signed_type = TYPE_INT16_T; + unsigned_type = TYPE_UINT16_T; + pointer_type = TYPE_COUNT_INT16_T_POINTER; + cp += 3; + } + else if (cp[1] == '3' && cp[2] == '2') + { + signed_type = TYPE_INT32_T; + unsigned_type = TYPE_UINT32_T; + pointer_type = TYPE_COUNT_INT32_T_POINTER; + cp += 3; + } + else if (cp[1] == '6' && cp[2] == '4') + { + signed_type = TYPE_INT64_T; + unsigned_type = TYPE_UINT64_T; + pointer_type = TYPE_COUNT_INT64_T_POINTER; + cp += 3; + } + } + } + else if (*cp == 'L') + { + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + floatingpoint_type = TYPE_LONGDOUBLE; + cp++; + } #if defined __APPLE__ && defined __MACH__ - /* On Mac OS X 10.3, PRIdMAX is defined as "qd". - We cannot change it to "lld" because PRIdMAX must also - be understood by the system's printf routines. */ - else if (*cp == 'q') - { - if (64 / 8 > sizeof (long)) - { - /* int64_t = long long */ - flags += 16; - } - else - { - /* int64_t = long */ - flags += 8; - } - cp++; - } + /* On Mac OS X 10.3, PRIdMAX is defined as "qd". + We cannot change it to "lld" because PRIdMAX must also + be understood by the system's printf routines. */ + else if (*cp == 'q') + { + if (64 / 8 > sizeof (long)) + { + /* int64_t = long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else + { + /* int64_t = long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp++; + } #endif #if defined _WIN32 && ! defined __CYGWIN__ - /* On native Windows, PRIdMAX is defined as "I64d". - We cannot change it to "lld" because PRIdMAX must also - be understood by the system's printf routines. */ - else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') - { - if (64 / 8 > sizeof (long)) - { - /* __int64 = long long */ - flags += 16; - } - else - { - /* __int64 = long */ - flags += 8; - } - cp += 3; - } + /* On native Windows, PRIdMAX is defined as "I64d". + We cannot change it to "lld" because PRIdMAX must also + be understood by the system's printf routines. */ + else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') + { + if (64 / 8 > sizeof (long)) + { + /* __int64_t = long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else + { + /* __int64_t = long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp += 3; + } #endif - else - break; - } + (void) pointer_type; - /* Read the conversion character. */ - c = *cp++; - switch (c) - { - case 'd': case 'i': - /* If 'long long' is larger than 'long': */ - if (flags >= 16 || (flags & 4)) - type = TYPE_LONGLONGINT; - else - /* If 'long long' is the same as 'long', we parse "lld" into - TYPE_LONGINT. */ - if (flags >= 8) - type = TYPE_LONGINT; - else if (flags & 2) - type = TYPE_SCHAR; - else if (flags & 1) - type = TYPE_SHORT; - else - type = TYPE_INT; - break; - case 'o': case 'u': case 'x': case 'X': - /* If 'unsigned long long' is larger than 'unsigned long': */ - if (flags >= 16 || (flags & 4)) - type = TYPE_ULONGLONGINT; - else - /* If 'unsigned long long' is the same as 'unsigned long', we - parse "llu" into TYPE_ULONGINT. */ - if (flags >= 8) - type = TYPE_ULONGINT; - else if (flags & 2) - type = TYPE_UCHAR; - else if (flags & 1) - type = TYPE_USHORT; - else - type = TYPE_UINT; - break; - case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': - case 'a': case 'A': - if (flags >= 16 || (flags & 4)) - type = TYPE_LONGDOUBLE; - else - type = TYPE_DOUBLE; - break; - case 'c': - if (flags >= 8) + /* Read the conversion character. */ + c = *cp++; + switch (c) + { + case 'd': case 'i': + type = signed_type; + break; + case 'b': case 'o': case 'u': case 'x': case 'X': + #if SUPPORT_GNU_PRINTF_DIRECTIVES \ + || (__GLIBC__ + (__GLIBC_MINOR__ >= 35) > 2) + case 'B': + #endif + type = unsigned_type; + break; + case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': + case 'a': case 'A': + type = floatingpoint_type; + break; + case 'c': + if (signed_type == TYPE_LONGINT + /* For backward compatibility only. */ + || signed_type == TYPE_LONGLONGINT) #if HAVE_WINT_T - type = TYPE_WIDE_CHAR; + type = TYPE_WIDE_CHAR; #else - goto error; + goto error; #endif - else - type = TYPE_CHAR; - break; + else + type = TYPE_CHAR; + break; #if HAVE_WINT_T - case 'C': - type = TYPE_WIDE_CHAR; - c = 'c'; - break; + case 'C': + type = TYPE_WIDE_CHAR; + c = 'c'; + break; #endif - case 's': - if (flags >= 8) + case 's': + if (signed_type == TYPE_LONGINT + /* For backward compatibility only. */ + || signed_type == TYPE_LONGLONGINT) #if HAVE_WCHAR_T - type = TYPE_WIDE_STRING; + type = TYPE_WIDE_STRING; #else - goto error; + goto error; #endif - else - type = TYPE_STRING; - break; + else + type = TYPE_STRING; + break; #if HAVE_WCHAR_T - case 'S': - type = TYPE_WIDE_STRING; - c = 's'; - break; + case 'S': + type = TYPE_WIDE_STRING; + c = 's'; + break; +#endif + case 'p': + type = TYPE_POINTER; + break; +#if NEED_PRINTF_WITH_N_DIRECTIVE + case 'n': + type = pointer_type; + break; #endif - case 'p': - type = TYPE_POINTER; - break; - case 'n': - /* If 'long long' is larger than 'long': */ - if (flags >= 16 || (flags & 4)) - type = TYPE_COUNT_LONGLONGINT_POINTER; - else - /* If 'long long' is the same as 'long', we parse "lln" into - TYPE_COUNT_LONGINT_POINTER. */ - if (flags >= 8) - type = TYPE_COUNT_LONGINT_POINTER; - else if (flags & 2) - type = TYPE_COUNT_SCHAR_POINTER; - else if (flags & 1) - type = TYPE_COUNT_SHORT_POINTER; - else - type = TYPE_COUNT_INT_POINTER; - break; #if ENABLE_UNISTDIO - /* The unistdio extensions. */ - case 'U': - if (flags >= 16) - type = TYPE_U32_STRING; - else if (flags >= 8) - type = TYPE_U16_STRING; - else - type = TYPE_U8_STRING; - break; + /* The unistdio extensions. */ + case 'U': + if (signed_type == TYPE_LONGLONGINT) + type = TYPE_U32_STRING; + else if (signed_type == TYPE_LONGINT) + type = TYPE_U16_STRING; + else + type = TYPE_U8_STRING; + break; #endif - case '%': - type = TYPE_NONE; - break; - default: - /* Unknown conversion character. */ - goto error; - } - } + case '%': + type = TYPE_NONE; + break; + default: + /* Unknown conversion character. */ + goto error; + } if (type != TYPE_NONE) { diff --git a/gl/printf-parse.h b/gl/printf-parse.h index 1f86e32..949b875 100644 --- a/gl/printf-parse.h +++ b/gl/printf-parse.h @@ -1,5 +1,5 @@ /* Parse printf format string. - Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2023 Free Software + Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -61,7 +61,7 @@ typedef struct const char* precision_start; const char* precision_end; size_t precision_arg_index; - char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ + char conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } char_directive; @@ -91,7 +91,7 @@ typedef struct const uint8_t* precision_start; const uint8_t* precision_end; size_t precision_arg_index; - uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ + uint8_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u8_directive; @@ -119,7 +119,7 @@ typedef struct const uint16_t* precision_start; const uint16_t* precision_end; size_t precision_arg_index; - uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ + uint16_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u16_directive; @@ -147,7 +147,7 @@ typedef struct const uint32_t* precision_start; const uint32_t* precision_end; size_t precision_arg_index; - uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ + uint32_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u32_directive; diff --git a/gl/realloc.c b/gl/realloc.c index 1063eb0..0573139 100644 --- a/gl/realloc.c +++ b/gl/realloc.c @@ -1,6 +1,6 @@ /* realloc() function that is glibc compatible. - Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2023 Free Software + Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify diff --git a/gl/reallocarray.c b/gl/reallocarray.c index 8c99250..09711a0 100644 --- a/gl/reallocarray.c +++ b/gl/reallocarray.c @@ -1,6 +1,6 @@ /* reallocarray function that is glibc compatible. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/regcomp.c b/gl/regcomp.c index 8947839..696cf81 100644 --- a/gl/regcomp.c +++ b/gl/regcomp.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2023 Free Software Foundation, Inc. + Copyright (C) 2002-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -905,7 +905,7 @@ init_word_char (re_dfa_t *dfa) bitset_word_t bits3 = 0x07fffffe; if (BITSET_WORD_BITS == 64) { - /* Pacify gcc -Woverflow on 32-bit platformns. */ + /* Pacify gcc -Woverflow on 32-bit platforms. */ dfa->word_char[0] = bits1 << 31 << 1 | bits0; dfa->word_char[1] = bits3 << 31 << 1 | bits2; i = 2; diff --git a/gl/regex.c b/gl/regex.c index 3beb0de..4b1a6ed 100644 --- a/gl/regex.c +++ b/gl/regex.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2023 Free Software Foundation, Inc. + Copyright (C) 2002-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -26,10 +26,6 @@ # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" # pragma GCC diagnostic ignored "-Wvla" # endif -# if __GNUC_PREREQ (4, 3) -# pragma GCC diagnostic ignored "-Wold-style-definition" -# pragma GCC diagnostic ignored "-Wtype-limits" -# endif #endif /* Make sure no one compiles this code with a C++ compiler. */ diff --git a/gl/regex.h b/gl/regex.h index 9ef0252..ccf40ce 100644 --- a/gl/regex.h +++ b/gl/regex.h @@ -1,6 +1,6 @@ /* Definitions for data structures and routines for the regular expression library. - Copyright (C) 1985, 1989-2023 Free Software Foundation, Inc. + Copyright (C) 1985, 1989-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/gl/regex_internal.c b/gl/regex_internal.c index 998a19b..8cd096e 100644 --- a/gl/regex_internal.c +++ b/gl/regex_internal.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2023 Free Software Foundation, Inc. + Copyright (C) 2002-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . diff --git a/gl/regex_internal.h b/gl/regex_internal.h index 149ec2e..6165cb1 100644 --- a/gl/regex_internal.h +++ b/gl/regex_internal.h @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2023 Free Software Foundation, Inc. + Copyright (C) 2002-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -29,6 +29,7 @@ #include #include #include +#include #include #ifndef _LIBC @@ -150,9 +151,6 @@ as some non-GCC platforms lack them, an issue when this code is used in Gnulib. */ -#ifndef SSIZE_MAX -# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) -#endif #ifndef ULONG_WIDTH # define ULONG_WIDTH REGEX_UINTEGER_WIDTH (ULONG_MAX) /* The number of usable bits in an unsigned integer type with maximum @@ -822,7 +820,7 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx) } #ifdef _LIBC -# if __GNUC__ >= 7 +# if __glibc_has_attribute (__fallthrough__) # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) diff --git a/gl/regexec.c b/gl/regexec.c index 13e0349..9f065df 100644 --- a/gl/regexec.c +++ b/gl/regexec.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2023 Free Software Foundation, Inc. + Copyright (C) 2002-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -324,7 +324,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1, char *s = NULL; if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0 - || INT_ADD_WRAPV (length1, length2, &len)))) + || ckd_add (&len, length1, length2)))) return -2; /* Concatenate the strings. */ diff --git a/gl/setenv.c b/gl/setenv.c index f0b8899..9e2e9e2 100644 --- a/gl/setenv.c +++ b/gl/setenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1995-2003, 2005-2023 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995-2003, 2005-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. This file is free software: you can redistribute it and/or modify @@ -82,6 +82,7 @@ typedef int (*compar_fn_t) (const void *, const void *); static void *known_values; # define KNOWN_VALUE(Str) \ + __extension__ \ ({ \ void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \ value != NULL ? *(char **) value : NULL; \ @@ -375,6 +376,11 @@ rpl_setenv (const char *name, const char *value, int replace) int saved_errno; size_t len = strlen (value); tmp = malloca (len + 2); + if (tmp == NULL) + { + errno = ENOMEM; + return -1; + } /* Since leading '=' is eaten, double it up. */ *tmp = '='; memcpy (tmp + 1, value, len + 1); diff --git a/gl/setlocale-lock.c b/gl/setlocale-lock.c index b70ba09..192489c 100644 --- a/gl/setlocale-lock.c +++ b/gl/setlocale-lock.c @@ -1,5 +1,5 @@ /* Return the internal lock used by setlocale_null_r. - Copyright (C) 2019-2023 Free Software Foundation, Inc. + Copyright (C) 2019-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,9 +18,10 @@ #include +/* The option '--disable-threads' explicitly requests no locking. */ /* When it is known that the gl_get_setlocale_null_lock function is defined by a dependency library, it should not be defined here. */ -#if OMIT_SETLOCALE_LOCK +#if AVOID_ANY_THREADS || OMIT_SETLOCALE_LOCK /* This declaration is solely to ensure that after preprocessing this file is never empty. */ @@ -37,14 +38,14 @@ typedef int dummy; /* Macro for exporting a symbol (function, not variable) defined in this file, when compiled into a shared library. */ -# ifndef DLL_EXPORTED +# ifndef SHLIB_EXPORTED # if HAVE_VISIBILITY /* Override the effect of the compiler option '-fvisibility=hidden'. */ -# define DLL_EXPORTED __attribute__((__visibility__("default"))) +# define SHLIB_EXPORTED __attribute__((__visibility__("default"))) # elif defined _WIN32 || defined __CYGWIN__ -# define DLL_EXPORTED __declspec(dllexport) +# define SHLIB_EXPORTED __declspec(dllexport) # else -# define DLL_EXPORTED +# define SHLIB_EXPORTED # endif # endif @@ -59,7 +60,7 @@ typedef int dummy; because the latter is not guaranteed to be a stable ABI in the future. */ /* Make sure the function gets exported from DLLs. */ -DLL_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void); +SHLIB_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void); static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT; static CRITICAL_SECTION lock; @@ -96,7 +97,7 @@ gl_get_setlocale_null_lock (void) static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* Make sure the function gets exported from shared libraries. */ -DLL_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void); +SHLIB_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void); /* Returns the internal lock used by setlocale_null_r. */ pthread_mutex_t * @@ -123,7 +124,7 @@ atomic_init (void) } /* Make sure the function gets exported from shared libraries. */ -DLL_EXPORTED mtx_t *gl_get_setlocale_null_lock (void); +SHLIB_EXPORTED mtx_t *gl_get_setlocale_null_lock (void); /* Returns the internal lock used by setlocale_null_r. */ mtx_t * diff --git a/gl/setlocale_null-unlocked.c b/gl/setlocale_null-unlocked.c new file mode 100644 index 0000000..0a86f0d --- /dev/null +++ b/gl/setlocale_null-unlocked.c @@ -0,0 +1,149 @@ +/* Query the name of the current global locale, without locking. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +/* Specification. */ +#include "setlocale_null.h" + +#include +#include +#include +#if defined _WIN32 && !defined __CYGWIN__ +# include +#endif + +/* Use the system's setlocale() function, not the gnulib override, here. */ +#undef setlocale + +const char * +setlocale_null_unlocked (int category) +{ + const char *result = setlocale (category, NULL); + +#ifdef __ANDROID__ + if (result == NULL) + switch (category) + { + case LC_CTYPE: + case LC_NUMERIC: + case LC_TIME: + case LC_COLLATE: + case LC_MONETARY: + case LC_MESSAGES: + case LC_ALL: + case LC_PAPER: + case LC_NAME: + case LC_ADDRESS: + case LC_TELEPHONE: + case LC_MEASUREMENT: + result = "C"; + break; + default: + break; + } +#endif + + return result; +} + +int +setlocale_null_r_unlocked (int category, char *buf, size_t bufsize) +{ +#if defined _WIN32 && !defined __CYGWIN__ && defined _MSC_VER + /* On native Windows, nowadays, the setlocale() implementation is based + on _wsetlocale() and uses malloc() for the result. We are better off + using _wsetlocale() directly. */ + const wchar_t *result = _wsetlocale (category, NULL); + + if (result == NULL) + { + /* CATEGORY is invalid. */ + if (bufsize > 0) + /* Return an empty string in BUF. + This is a convenience for callers that don't want to write explicit + code for handling EINVAL. */ + buf[0] = '\0'; + return EINVAL; + } + else + { + size_t length = wcslen (result); + if (length < bufsize) + { + size_t i; + + /* Convert wchar_t[] -> char[], assuming plain ASCII. */ + for (i = 0; i <= length; i++) + buf[i] = result[i]; + + return 0; + } + else + { + if (bufsize > 0) + { + /* Return a truncated result in BUF. + This is a convenience for callers that don't want to write + explicit code for handling ERANGE. */ + size_t i; + + /* Convert wchar_t[] -> char[], assuming plain ASCII. */ + for (i = 0; i < bufsize; i++) + buf[i] = result[i]; + buf[bufsize - 1] = '\0'; + } + return ERANGE; + } + } +#else + const char *result = setlocale_null_unlocked (category); + + if (result == NULL) + { + /* CATEGORY is invalid. */ + if (bufsize > 0) + /* Return an empty string in BUF. + This is a convenience for callers that don't want to write explicit + code for handling EINVAL. */ + buf[0] = '\0'; + return EINVAL; + } + else + { + size_t length = strlen (result); + if (length < bufsize) + { + memcpy (buf, result, length + 1); + return 0; + } + else + { + if (bufsize > 0) + { + /* Return a truncated result in BUF. + This is a convenience for callers that don't want to write + explicit code for handling ERANGE. */ + memcpy (buf, result, bufsize - 1); + buf[bufsize - 1] = '\0'; + } + return ERANGE; + } + } +#endif +} diff --git a/gl/setlocale_null.c b/gl/setlocale_null.c index 6ac563d..5ecf413 100644 --- a/gl/setlocale_null.c +++ b/gl/setlocale_null.c @@ -1,5 +1,5 @@ /* Query the name of the current global locale. - Copyright (C) 2019-2023 Free Software Foundation, Inc. + Copyright (C) 2019-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -25,12 +25,14 @@ #include #include #include -#if defined _WIN32 && !defined __CYGWIN__ -# include -#endif #if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) -# if defined _WIN32 && !defined __CYGWIN__ + +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ + +# elif defined _WIN32 && !defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN /* avoid including junk */ # include @@ -51,154 +53,40 @@ # include # endif -#endif -/* Use the system's setlocale() function, not the gnulib override, here. */ -#undef setlocale - -static const char * -setlocale_null_androidfix (int category) -{ - const char *result = setlocale (category, NULL); - -#ifdef __ANDROID__ - if (result == NULL) - switch (category) - { - case LC_CTYPE: - case LC_NUMERIC: - case LC_TIME: - case LC_COLLATE: - case LC_MONETARY: - case LC_MESSAGES: - case LC_ALL: - case LC_PAPER: - case LC_NAME: - case LC_ADDRESS: - case LC_TELEPHONE: - case LC_MEASUREMENT: - result = "C"; - break; - default: - break; - } #endif - return result; -} - -static int -setlocale_null_unlocked (int category, char *buf, size_t bufsize) -{ -#if defined _WIN32 && !defined __CYGWIN__ && defined _MSC_VER - /* On native Windows, nowadays, the setlocale() implementation is based - on _wsetlocale() and uses malloc() for the result. We are better off - using _wsetlocale() directly. */ - const wchar_t *result = _wsetlocale (category, NULL); - - if (result == NULL) - { - /* CATEGORY is invalid. */ - if (bufsize > 0) - /* Return an empty string in BUF. - This is a convenience for callers that don't want to write explicit - code for handling EINVAL. */ - buf[0] = '\0'; - return EINVAL; - } - else - { - size_t length = wcslen (result); - if (length < bufsize) - { - size_t i; - - /* Convert wchar_t[] -> char[], assuming plain ASCII. */ - for (i = 0; i <= length; i++) - buf[i] = result[i]; +#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */ - return 0; - } - else - { - if (bufsize > 0) - { - /* Return a truncated result in BUF. - This is a convenience for callers that don't want to write - explicit code for handling ERANGE. */ - size_t i; - - /* Convert wchar_t[] -> char[], assuming plain ASCII. */ - for (i = 0; i < bufsize; i++) - buf[i] = result[i]; - buf[bufsize - 1] = '\0'; - } - return ERANGE; - } - } -#else - const char *result = setlocale_null_androidfix (category); - - if (result == NULL) - { - /* CATEGORY is invalid. */ - if (bufsize > 0) - /* Return an empty string in BUF. - This is a convenience for callers that don't want to write explicit - code for handling EINVAL. */ - buf[0] = '\0'; - return EINVAL; - } - else - { - size_t length = strlen (result); - if (length < bufsize) - { - memcpy (buf, result, length + 1); - return 0; - } - else - { - if (bufsize > 0) - { - /* Return a truncated result in BUF. - This is a convenience for callers that don't want to write - explicit code for handling ERANGE. */ - memcpy (buf, result, bufsize - 1); - buf[bufsize - 1] = '\0'; - } - return ERANGE; - } - } -#endif -} - -#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */ - -/* Use a lock, so that no two threads can invoke setlocale_null_unlocked +/* Use a lock, so that no two threads can invoke setlocale_null_r_unlocked at the same time. */ /* Prohibit renaming this symbol. */ # undef gl_get_setlocale_null_lock -# if defined _WIN32 && !defined __CYGWIN__ +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ +# define setlocale_null_r_with_lock setlocale_null_r_unlocked + +# elif defined _WIN32 && !defined __CYGWIN__ extern __declspec(dllimport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void); static int -setlocale_null_with_lock (int category, char *buf, size_t bufsize) +setlocale_null_r_with_lock (int category, char *buf, size_t bufsize) { CRITICAL_SECTION *lock = gl_get_setlocale_null_lock (); int ret; EnterCriticalSection (lock); - ret = setlocale_null_unlocked (category, buf, bufsize); + ret = setlocale_null_r_unlocked (category, buf, bufsize); LeaveCriticalSection (lock); return ret; } -# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */ +# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */ extern # if defined _WIN32 || defined __CYGWIN__ @@ -223,7 +111,7 @@ extern # endif static int -setlocale_null_with_lock (int category, char *buf, size_t bufsize) +setlocale_null_r_with_lock (int category, char *buf, size_t bufsize) { if (pthread_in_use()) { @@ -232,14 +120,14 @@ setlocale_null_with_lock (int category, char *buf, size_t bufsize) if (pthread_mutex_lock (lock)) abort (); - ret = setlocale_null_unlocked (category, buf, bufsize); + ret = setlocale_null_r_unlocked (category, buf, bufsize); if (pthread_mutex_unlock (lock)) abort (); return ret; } else - return setlocale_null_unlocked (category, buf, bufsize); + return setlocale_null_r_unlocked (category, buf, bufsize); } # elif HAVE_THREADS_H @@ -247,14 +135,14 @@ setlocale_null_with_lock (int category, char *buf, size_t bufsize) extern mtx_t *gl_get_setlocale_null_lock (void); static int -setlocale_null_with_lock (int category, char *buf, size_t bufsize) +setlocale_null_r_with_lock (int category, char *buf, size_t bufsize) { mtx_t *lock = gl_get_setlocale_null_lock (); int ret; if (mtx_lock (lock) != thrd_success) abort (); - ret = setlocale_null_unlocked (category, buf, bufsize); + ret = setlocale_null_r_unlocked (category, buf, bufsize); if (mtx_unlock (lock) != thrd_success) abort (); @@ -271,27 +159,27 @@ setlocale_null_r (int category, char *buf, size_t bufsize) #if SETLOCALE_NULL_ALL_MTSAFE # if SETLOCALE_NULL_ONE_MTSAFE - return setlocale_null_unlocked (category, buf, bufsize); + return setlocale_null_r_unlocked (category, buf, bufsize); # else if (category == LC_ALL) - return setlocale_null_unlocked (category, buf, bufsize); + return setlocale_null_r_unlocked (category, buf, bufsize); else - return setlocale_null_with_lock (category, buf, bufsize); + return setlocale_null_r_with_lock (category, buf, bufsize); # endif #else # if SETLOCALE_NULL_ONE_MTSAFE if (category == LC_ALL) - return setlocale_null_with_lock (category, buf, bufsize); + return setlocale_null_r_with_lock (category, buf, bufsize); else - return setlocale_null_unlocked (category, buf, bufsize); + return setlocale_null_r_unlocked (category, buf, bufsize); # else - return setlocale_null_with_lock (category, buf, bufsize); + return setlocale_null_r_with_lock (category, buf, bufsize); # endif #endif @@ -301,7 +189,7 @@ const char * setlocale_null (int category) { #if SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE - return setlocale_null_androidfix (category); + return setlocale_null_unlocked (category); #else /* This call must be multithread-safe. To achieve this without using @@ -317,7 +205,7 @@ setlocale_null (int category) if (category == LC_ALL) { # if SETLOCALE_NULL_ALL_MTSAFE - return setlocale_null_androidfix (LC_ALL); + return setlocale_null_unlocked (LC_ALL); # else char buf[SETLOCALE_NULL_ALL_MAX]; static char resultbuf[SETLOCALE_NULL_ALL_MAX]; @@ -331,7 +219,7 @@ setlocale_null (int category) else { # if SETLOCALE_NULL_ONE_MTSAFE - return setlocale_null_androidfix (category); + return setlocale_null_unlocked (category); # else enum { diff --git a/gl/setlocale_null.h b/gl/setlocale_null.h index c740fa0..966c53c 100644 --- a/gl/setlocale_null.h +++ b/gl/setlocale_null.h @@ -1,5 +1,5 @@ /* Query the name of the current global locale. - Copyright (C) 2019-2023 Free Software Foundation, Inc. + Copyright (C) 2019-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -44,6 +44,34 @@ extern "C" { 55+5*58. */ #define SETLOCALE_NULL_ALL_MAX (148+12*256+1) +/* setlocale_null_r_unlocked (CATEGORY, BUF, BUFSIZE) is like + setlocale (CATEGORY, NULL), except that + - it returns the resulting locale category name or locale name in the + user-supplied buffer BUF, which must be BUFSIZE bytes long. + The recommended minimum buffer size is + - SETLOCALE_NULL_MAX for CATEGORY != LC_ALL, and + - SETLOCALE_NULL_ALL_MAX for CATEGORY == LC_ALL. + The return value is an error code: 0 if the call is successful, EINVAL if + CATEGORY is invalid, or ERANGE if BUFSIZE is smaller than the length needed + size (including the trailing NUL byte). In the latter case, a truncated + result is returned in BUF, but still NUL-terminated if BUFSIZE > 0. + This call is guaranteed to be multithread-safe only if + - CATEGORY != LC_ALL and SETLOCALE_NULL_ONE_MTSAFE is true, or + - CATEGORY == LC_ALL and SETLOCALE_NULL_ALL_MTSAFE is true, + and the other threads must not make other setlocale invocations (since + changing the global locale has side effects on all threads). */ +extern int setlocale_null_r_unlocked (int category, char *buf, size_t bufsize) + _GL_ARG_NONNULL ((2)); + +/* setlocale_null_unlocked (CATEGORY) is like setlocale (CATEGORY, NULL). + The return value is NULL if CATEGORY is invalid. + This call is guaranteed to be multithread-safe only if + - CATEGORY != LC_ALL and SETLOCALE_NULL_ONE_MTSAFE is true, or + - CATEGORY == LC_ALL and SETLOCALE_NULL_ALL_MTSAFE is true, + and the other threads must not make other setlocale invocations (since + changing the global locale has side effects on all threads). */ +extern const char *setlocale_null_unlocked (int category); + /* setlocale_null_r (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL), except that - it is guaranteed to be multithread-safe, diff --git a/gl/sha256-stream.c b/gl/sha256-stream.c index 0e83380..08d24b7 100644 --- a/gl/sha256-stream.c +++ b/gl/sha256-stream.c @@ -1,7 +1,7 @@ /* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or memory blocks according to the NIST specification FIPS-180-2. - Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/sha256.c b/gl/sha256.c index e5fea02..fe7c544 100644 --- a/gl/sha256.c +++ b/gl/sha256.c @@ -1,7 +1,7 @@ /* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or memory blocks according to the NIST specification FIPS-180-2. - Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/sha256.h b/gl/sha256.h index 2879477..a9d7abb 100644 --- a/gl/sha256.h +++ b/gl/sha256.h @@ -1,6 +1,6 @@ /* Declarations of functions and data types used for SHA256 and SHA224 sum library functions. - Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,6 +18,11 @@ #ifndef SHA256_H # define SHA256_H 1 +/* This file uses HAVE_OPENSSL_SHA256. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + # include # include @@ -25,7 +30,21 @@ # ifndef OPENSSL_API_COMPAT # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif -# include +/* If would give a compile-time error, don't use OpenSSL. */ +# include +# if OPENSSL_VERSION_MAJOR >= 3 +# include +# if (OPENSSL_CONFIGURED_API \ + < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \ + ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \ + + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \ + + ((OPENSSL_API_COMPAT >> 12) & 0xFF))) +# undef HAVE_OPENSSL_SHA256 +# endif +# endif +# if HAVE_OPENSSL_SHA256 +# include +# endif # endif # ifdef __cplusplus diff --git a/gl/size_max.h b/gl/size_max.h index 48af025..bd2eb43 100644 --- a/gl/size_max.h +++ b/gl/size_max.h @@ -1,5 +1,5 @@ /* size_max.h -- declare SIZE_MAX through system headers - Copyright (C) 2005-2006, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc. Written by Simon Josefsson. This file is free software: you can redistribute it and/or modify @@ -18,6 +18,11 @@ #ifndef GNULIB_SIZE_MAX_H #define GNULIB_SIZE_MAX_H +/* This file uses HAVE_STDINT_H. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Get SIZE_MAX declaration on systems like Solaris 7/8/9. */ # include /* Get SIZE_MAX declaration on systems like glibc 2. */ diff --git a/gl/snprintf.c b/gl/snprintf.c index cdff314..c1b9356 100644 --- a/gl/snprintf.c +++ b/gl/snprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 2004, 2006-2023 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc. Written by Simon Josefsson and Paul Eggert. This file is free software: you can redistribute it and/or modify diff --git a/gl/sockets.c b/gl/sockets.c index ca99db8..92beb7d 100644 --- a/gl/sockets.c +++ b/gl/sockets.c @@ -1,6 +1,6 @@ /* sockets.c --- wrappers for Windows socket functions - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/sockets.h b/gl/sockets.h index a0b1601..55077ae 100644 --- a/gl/sockets.h +++ b/gl/sockets.h @@ -1,6 +1,6 @@ /* sockets.h - wrappers for Windows socket functions - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -20,6 +20,15 @@ #ifndef SOCKETS_H #define SOCKETS_H 1 +/* This file uses _GL_ATTRIBUTE_CONST. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#ifdef __cplusplus +extern "C" { +#endif + #define SOCKETS_1_0 0x0001 #define SOCKETS_1_1 0x0101 #define SOCKETS_2_0 0x0002 @@ -38,6 +47,11 @@ int gl_sockets_cleanup (void) #endif ; +#ifdef __cplusplus +} +#endif + + /* This function is useful it you create a socket using gnulib's Winsock wrappers but needs to pass on the socket handle to some other library that only accepts sockets. */ diff --git a/gl/stat-time.c b/gl/stat-time.c index bc28223..1ab01f5 100644 --- a/gl/stat-time.c +++ b/gl/stat-time.c @@ -1,6 +1,6 @@ /* stat-related time functions. - Copyright (C) 2012-2023 Free Software Foundation, Inc. + Copyright (C) 2012-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/stat-time.h b/gl/stat-time.h index 92aa1e6..3cd8478 100644 --- a/gl/stat-time.h +++ b/gl/stat-time.h @@ -1,6 +1,6 @@ /* stat-related time functions. - Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -20,15 +20,18 @@ #ifndef STAT_TIME_H #define STAT_TIME_H 1 +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNUSED, + _GL_ATTRIBUTE_PURE, HAVE_STRUCT_STAT_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include #include #include #include -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_STAT_TIME_INLINE # define _GL_STAT_TIME_INLINE _GL_INLINE @@ -49,11 +52,13 @@ extern "C" { #if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC # if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC # define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim) +# define STAT_TIMESPEC_OFFSETOF(st_xtim) offsetof (struct stat, st_xtim) # else # define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec) # endif #elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC # define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec) +# define STAT_TIMESPEC_OFFSETOF(st_xtim) offsetof (struct stat, st_xtim##espec) #elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC # define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec) #elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC @@ -119,10 +124,8 @@ get_stat_atime (struct stat const *st) #ifdef STAT_TIMESPEC return STAT_TIMESPEC (st, st_atim); #else - struct timespec t; - t.tv_sec = st->st_atime; - t.tv_nsec = get_stat_atime_ns (st); - return t; + return (struct timespec) { .tv_sec = st->st_atime, + .tv_nsec = get_stat_atime_ns (st) }; #endif } @@ -133,10 +136,8 @@ get_stat_ctime (struct stat const *st) #ifdef STAT_TIMESPEC return STAT_TIMESPEC (st, st_ctim); #else - struct timespec t; - t.tv_sec = st->st_ctime; - t.tv_nsec = get_stat_ctime_ns (st); - return t; + return (struct timespec) { .tv_sec = st->st_ctime, + .tv_nsec = get_stat_ctime_ns (st) }; #endif } @@ -147,10 +148,8 @@ get_stat_mtime (struct stat const *st) #ifdef STAT_TIMESPEC return STAT_TIMESPEC (st, st_mtim); #else - struct timespec t; - t.tv_sec = st->st_mtime; - t.tv_nsec = get_stat_mtime_ns (st); - return t; + return (struct timespec) { .tv_sec = st->st_mtime, + .tv_nsec = get_stat_mtime_ns (st) }; #endif } @@ -165,8 +164,8 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st) || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC) t = STAT_TIMESPEC (st, st_birthtim); #elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC - t.tv_sec = st->st_birthtime; - t.tv_nsec = st->st_birthtimensec; + t = (struct timespec) { .tv_sec = st->st_birthtime, + .tv_nsec = st->st_birthtimensec }; #elif defined _WIN32 && ! defined __CYGWIN__ /* Native Windows platforms (but not Cygwin) put the "file creation time" in st_ctime (!). See @@ -174,13 +173,11 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st) # if _GL_WINDOWS_STAT_TIMESPEC t = st->st_ctim; # else - t.tv_sec = st->st_ctime; - t.tv_nsec = 0; + t = (struct timespec) { .tv_sec = st->st_ctime }; # endif #else /* Birth time is not supported. */ - t.tv_sec = -1; - t.tv_nsec = -1; + t = (struct timespec) { .tv_sec = -1, .tv_nsec = -1 }; #endif #if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ @@ -192,30 +189,28 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st) sometimes returns junk in the birth time fields; work around this bug if it is detected. */ if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000)) - { - t.tv_sec = -1; - t.tv_nsec = -1; - } + t = (struct timespec) { .tv_sec = -1, .tv_nsec = -1 }; #endif return t; } /* If a stat-like function returned RESULT, normalize the timestamps - in *ST, in case this platform suffers from the Solaris 11 bug where + in *ST, if this platform suffers from a macOS and Solaris bug where tv_nsec might be negative. Return the adjusted RESULT, setting errno to EOVERFLOW if normalization overflowed. This function is intended to be private to this .h file. */ _GL_STAT_TIME_INLINE int stat_time_normalize (int result, _GL_UNUSED struct stat *st) { -#if defined __sun && defined STAT_TIMESPEC +#if (((defined __APPLE__ && defined __MACH__) || defined __sun) \ + && defined STAT_TIMESPEC_OFFSETOF) if (result == 0) { long int timespec_hz = 1000000000; - short int const ts_off[] = { offsetof (struct stat, st_atim), - offsetof (struct stat, st_mtim), - offsetof (struct stat, st_ctim) }; + short int const ts_off[] = { STAT_TIMESPEC_OFFSETOF (st_atim), + STAT_TIMESPEC_OFFSETOF (st_mtim), + STAT_TIMESPEC_OFFSETOF (st_ctim) }; int i; for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++) { @@ -229,8 +224,7 @@ stat_time_normalize (int result, _GL_UNUSED struct stat *st) } ts->tv_nsec = r; /* Overflow is possible, as Solaris 11 stat can yield - tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. - INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */ + tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. */ if (ckd_add (&ts->tv_sec, q, ts->tv_sec)) { errno = EOVERFLOW; diff --git a/gl/stat-w32.c b/gl/stat-w32.c index 2f01197..ddd6f59 100644 --- a/gl/stat-w32.c +++ b/gl/stat-w32.c @@ -1,5 +1,5 @@ /* Core of implementation of fstat and stat for native Windows. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/stat-w32.h b/gl/stat-w32.h index c673874..392faed 100644 --- a/gl/stat-w32.h +++ b/gl/stat-w32.h @@ -1,5 +1,5 @@ /* Core of implementation of fstat and stat for native Windows. - Copyright (C) 2017-2023 Free Software Foundation, Inc. + Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/stat.c b/gl/stat.c index 7987e26..ecf9f9b 100644 --- a/gl/stat.c +++ b/gl/stat.c @@ -1,5 +1,5 @@ /* Work around platform bugs in stat. - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/stdalign.in.h b/gl/stdalign.in.h deleted file mode 100644 index 7f9dbb4..0000000 --- a/gl/stdalign.in.h +++ /dev/null @@ -1,137 +0,0 @@ -/* A substitute for ISO C11 . - - Copyright 2011-2023 Free Software Foundation, Inc. - - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - This file is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -/* Written by Paul Eggert and Bruno Haible. */ - -#ifndef _GL_STDALIGN_H -#define _GL_STDALIGN_H - -/* ISO C11 for platforms that lack it. - - References: - ISO C11 (latest free draft - ) - sections 6.5.3.4, 6.7.5, 7.15. - C++11 (latest free draft - ) - section 18.10. */ - -/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment - requirement of a structure member (i.e., slot or field) that is of - type TYPE, as an integer constant expression. - - This differs from GCC's and clang's __alignof__ operator, which can - yield a better-performing alignment for an object of that type. For - example, on x86 with GCC and on Linux/x86 with clang, - __alignof__ (double) and __alignof__ (long long) are 8, whereas - alignof (double) and alignof (long long) are 4 unless the option - '-malign-double' is used. - - The result cannot be used as a value for an 'enum' constant, if you - want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ - -/* FreeBSD 9.1 , included by and lots of other - standard headers, defines conflicting implementations of _Alignas - and _Alignof that are no better than ours; override them. */ -#undef _Alignas -#undef _Alignof - -/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 - . - clang versions < 8.0.0 have the same bug. */ -#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ - || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ - && !defined __clang__) \ - || (defined __clang__ && __clang_major__ < 8)) -# ifdef __cplusplus -# if (201103 <= __cplusplus || defined _MSC_VER) -# define _Alignof(type) alignof (type) -# else - template struct __alignof_helper { char __a; __t __b; }; -# define _Alignof(type) offsetof (__alignof_helper, __b) -# define _GL_STDALIGN_NEEDS_STDDEF 1 -# endif -# else -# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ -# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) -# else -# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) -# define _GL_STDALIGN_NEEDS_STDDEF 1 -# endif -# endif -#endif -#if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) -# define alignof _Alignof -#endif -#define __alignof_is_defined 1 - -/* alignas (A), also known as _Alignas (A), aligns a variable or type - to the alignment A, where A is an integer constant expression. For - example: - - int alignas (8) foo; - struct s { int a; int alignas (8) bar; }; - - aligns the address of FOO and the offset of BAR to be multiples of 8. - - A should be a power of two that is at least the type's alignment - and at most the implementation's alignment limit. This limit is - 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable - to MSVC through at least version 10.0, A should be an integer - constant, as MSVC does not support expressions such as 1 << 3. - To be portable to Sun C 5.11, do not align auto variables to - anything stricter than their default alignment. - - The following C11 requirements are not supported here: - - - If A is zero, alignas has no effect. - - alignas can be used multiple times; the strictest one wins. - - alignas (TYPE) is equivalent to alignas (alignof (TYPE)). - - */ - -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 -# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER) -# define _Alignas(a) alignas (a) -# elif (!defined __attribute__ \ - && ((defined __APPLE__ && defined __MACH__ \ - ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ - : __GNUC__ && !defined __ibmxl__) \ - || (4 <= __clang_major__) \ - || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \ - || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)) -# define _Alignas(a) __attribute__ ((__aligned__ (a))) -# elif 1300 <= _MSC_VER -# define _Alignas(a) __declspec (align (a)) -# endif -#endif -#if ((defined _Alignas \ - && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \ - || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) -# define alignas _Alignas -#endif -#if (defined alignas \ - || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) -# define __alignas_is_defined 1 -#endif - -/* Include if needed for offsetof. */ -#if _GL_STDALIGN_NEEDS_STDDEF -# include -#endif - -#endif /* _GL_STDALIGN_H */ diff --git a/gl/stdckdint.in.h b/gl/stdckdint.in.h index 71bab5f..9184880 100644 --- a/gl/stdckdint.in.h +++ b/gl/stdckdint.in.h @@ -1,6 +1,6 @@ /* stdckdint.h -- checked integer arithmetic - Copyright 2022-2023 Free Software Foundation, Inc. + Copyright 2022-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published diff --git a/gl/stddef.in.h b/gl/stddef.in.h index 6eadcc3..fa8998d 100644 --- a/gl/stddef.in.h +++ b/gl/stddef.in.h @@ -1,6 +1,6 @@ /* A substitute for POSIX 2008 , for platforms that have issues. - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,7 +18,7 @@ /* Written by Eric Blake. */ /* - * POSIX 2008 for platforms that have issues. + * POSIX 2008 and ISO C 23 for platforms that have issues. * */ @@ -37,9 +37,9 @@ remember if special invocation has ever been used to obtain wint_t, in which case we need to clean up NULL yet again. */ -# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) +# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _@GUARD_PREFIX@_STDDEF_WINT_T) # ifdef __need_wint_t -# define _GL_STDDEF_WINT_T +# define _@GUARD_PREFIX@_STDDEF_WINT_T # endif # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ /* On TinyCC, make sure that the macros that indicate the special invocation @@ -58,7 +58,7 @@ /* On AIX 7.2, with xlc in 64-bit mode, defines max_align_t to a type with alignment 4, but 'long' has alignment 8. */ -# if defined _AIX && defined __LP64__ +# if defined _AIX && defined __LP64__ && !@HAVE_MAX_ALIGN_T@ # if !GNULIB_defined_max_align_t # ifdef _MAX_ALIGN_T /* /usr/include/stddef.h has already defined max_align_t. Override it. */ @@ -69,6 +69,7 @@ typedef long rpl_max_align_t; typedef long max_align_t; # define _MAX_ALIGN_T # endif +# define __CLANG_MAX_ALIGN_T_DEFINED # define GNULIB_defined_max_align_t 1 # endif # endif @@ -79,7 +80,7 @@ typedef long max_align_t; /* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ # if (@REPLACE_NULL@ \ - && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T)) + && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _@GUARD_PREFIX@_STDDEF_WINT_T)) # undef NULL # ifdef __cplusplus /* ISO C++ says that the macro NULL must expand to an integer constant @@ -100,6 +101,33 @@ typedef long max_align_t; # ifndef _@GUARD_PREFIX@_STDDEF_H # define _@GUARD_PREFIX@_STDDEF_H +/* This file uses _Noreturn, _GL_ATTRIBUTE_NOTHROW. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + /* Some platforms lack wchar_t. */ #if !@HAVE_WCHAR_T@ # define wchar_t int @@ -137,11 +165,49 @@ typedef union long int __i _GL_STDDEF_ALIGNAS (long int); } rpl_max_align_t; # define max_align_t rpl_max_align_t +# define __CLANG_MAX_ALIGN_T_DEFINED # define GNULIB_defined_max_align_t 1 # endif # endif #endif +/* ISO C 23 § 7.21.1 The unreachable macro */ +#ifndef unreachable + +/* Code borrowed from verify.h. */ +# ifndef _GL_HAS_BUILTIN_UNREACHABLE +# if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# define _GL_HAS_BUILTIN_UNREACHABLE 1 +# elif defined __has_builtin +# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) +# else +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# endif +# endif + +# if _GL_HAS_BUILTIN_UNREACHABLE +# define unreachable() __builtin_unreachable () +# elif 1200 <= _MSC_VER +# define unreachable() __assume (0) +# else +/* Declare abort(), without including . */ +extern +# if defined __cplusplus +"C" +# endif +_Noreturn +void abort (void) +# if defined __cplusplus && (__GLIBC__ >= 2) +_GL_ATTRIBUTE_NOTHROW +# endif +; +# define unreachable() abort () +# endif + +#endif + # endif /* _@GUARD_PREFIX@_STDDEF_H */ # endif /* _@GUARD_PREFIX@_STDDEF_H */ #endif /* __need_XXX */ diff --git a/gl/stdint.in.h b/gl/stdint.in.h index 5ddc644..fea7483 100644 --- a/gl/stdint.in.h +++ b/gl/stdint.in.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2002, 2004-2023 Free Software Foundation, Inc. +/* Copyright (C) 2001-2002, 2004-2024 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. This file is part of gnulib. @@ -306,6 +306,8 @@ typedef gl_uint_fast32_t gl_uint_fast16_t; uintptr_t to avoid conflicting declarations of system functions like _findclose in . */ # if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \ + || (defined __INTPTR_WIDTH__ \ + && __INTPTR_WIDTH__ != (defined _WIN64 ? LLONG_WIDTH : LONG_WIDTH)) \ || defined __MINGW32__) # undef intptr_t # undef uintptr_t diff --git a/gl/stdio-impl.h b/gl/stdio-impl.h index 46608be..63ebf7c 100644 --- a/gl/stdio-impl.h +++ b/gl/stdio-impl.h @@ -1,5 +1,5 @@ /* Implementation details of FILE streams. - Copyright (C) 2007-2008, 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2008, 2010-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/stdio-read.c b/gl/stdio-read.c index 6e2984c..253b8aa 100644 --- a/gl/stdio-read.c +++ b/gl/stdio-read.c @@ -1,5 +1,5 @@ /* POSIX compatible FILE stream read function. - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2011. This file is free software: you can redistribute it and/or modify diff --git a/gl/stdio-write.c b/gl/stdio-write.c index 9cf36cc..ca6aa00 100644 --- a/gl/stdio-write.c +++ b/gl/stdio-write.c @@ -1,5 +1,5 @@ /* POSIX compatible FILE stream write function. - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This file is free software: you can redistribute it and/or modify diff --git a/gl/stdio.in.h b/gl/stdio.in.h index 59cbea3..35b9f74 100644 --- a/gl/stdio.in.h +++ b/gl/stdio.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 2004, 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2004, 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -36,6 +36,18 @@ #ifndef _@GUARD_PREFIX@_STDIO_H +/* Suppress macOS deprecation warnings for sprintf and vsprintf. */ +#if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE +# ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +# include +# endif +# if (defined MAC_OS_X_VERSION_MIN_REQUIRED \ + && 130000 <= MAC_OS_X_VERSION_MIN_REQUIRED) +# define _POSIX_C_SOURCE 200809L +# define _GL_DEFINED__POSIX_C_SOURCE +# endif +#endif + #define _GL_ALREADY_INCLUDING_STDIO_H /* The include_next requires a split double-inclusion guard. */ @@ -43,9 +55,21 @@ #undef _GL_ALREADY_INCLUDING_STDIO_H +#ifdef _GL_DEFINED__POSIX_C_SOURCE +# undef _GL_DEFINED__POSIX_C_SOURCE +# undef _POSIX_C_SOURCE +#endif + #ifndef _@GUARD_PREFIX@_STDIO_H #define _@GUARD_PREFIX@_STDIO_H +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT, + _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Get va_list. Needed on many systems, including glibc 2.8. */ #include @@ -116,6 +140,38 @@ # endif #endif +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 || defined __clang__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + /* An __attribute__ __format__ specifier for a function that takes a format string and arguments, where the format string directives are the ones standardized by ISO C99 and POSIX. @@ -193,6 +249,36 @@ # undef putc_unlocked #endif + +/* Maximum number of characters produced by printing a NaN value. */ +#ifndef _PRINTF_NAN_LEN_MAX +# if defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ \ + || (defined __APPLE__ && defined __MACH__) +/* On BSD systems, a NaN value prints as just "nan", without a sign. */ +# define _PRINTF_NAN_LEN_MAX 3 +# elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __OpenBSD__ || defined __sun || defined __CYGWIN__ +/* glibc, musl libc, OpenBSD, Solaris libc, and Cygwin produce "[-]nan". */ +# define _PRINTF_NAN_LEN_MAX 4 +# elif defined _AIX +/* AIX produces "[-]NaNQ". */ +# define _PRINTF_NAN_LEN_MAX 5 +# elif defined _WIN32 && !defined __CYGWIN__ +/* On native Windows, the output can be: + - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)", + - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */ +# define _PRINTF_NAN_LEN_MAX 10 +# elif defined __sgi +/* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal + digits. */ +# define _PRINTF_NAN_LEN_MAX 14 +# else +/* We don't know, but 32 should be a safe maximum. */ +# define _PRINTF_NAN_LEN_MAX 32 +# endif +#endif + + #if @GNULIB_DPRINTF@ # if @REPLACE_DPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -210,7 +296,9 @@ _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...) # endif _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (dprintf); +# endif #elif defined GNULIB_POSIXCHECK # undef dprintf # if HAVE_RAW_DECL_DPRINTF @@ -273,7 +361,8 @@ _GL_CXXALIASWARN (fcloseall); # endif _GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) - _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); # elif defined _WIN32 && !defined __CYGWIN__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -284,9 +373,18 @@ _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); # else # if __GNUC__ >= 11 /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (fdopen, FILE *, (int fd, const char *mode) - _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# else +_GL_FUNCDECL_SYS (fdopen, FILE *, + (int fd, const char *mode) + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# endif # endif _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); # endif @@ -294,9 +392,18 @@ _GL_CXXALIASWARN (fdopen); #else # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (fdopen, FILE *, + (int fd, const char *mode) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# else _GL_FUNCDECL_SYS (fdopen, FILE *, (int fd, const char *mode) - _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# endif # endif # if defined GNULIB_POSIXCHECK # undef fdopen @@ -407,7 +514,8 @@ _GL_CXXALIASWARN (fileno); # endif _GL_FUNCDECL_RPL (fopen, FILE *, (const char *restrict filename, const char *restrict mode) - _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (fopen, FILE *, (const char *restrict filename, const char *restrict mode)); # else @@ -799,14 +907,14 @@ _GL_CXXALIAS_SYS (fwrite, size_t, && !defined __cplusplus) # undef fwrite # undef fwrite_unlocked -extern size_t __REDIRECT (rpl_fwrite, - (const void *__restrict, size_t, size_t, - FILE *__restrict), - fwrite); -extern size_t __REDIRECT (rpl_fwrite_unlocked, - (const void *__restrict, size_t, size_t, - FILE *__restrict), - fwrite_unlocked); +_GL_EXTERN_C size_t __REDIRECT (rpl_fwrite, + (const void *__restrict, size_t, size_t, + FILE *__restrict), + fwrite); +_GL_EXTERN_C size_t __REDIRECT (rpl_fwrite_unlocked, + (const void *__restrict, size_t, size_t, + FILE *__restrict), + fwrite_unlocked); # define fwrite rpl_fwrite # define fwrite_unlocked rpl_fwrite_unlocked # endif @@ -882,7 +990,9 @@ _GL_CXXALIAS_SYS (getdelim, ssize_t, int delimiter, FILE *restrict stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getdelim); +# endif #elif defined GNULIB_POSIXCHECK # undef getdelim # if HAVE_RAW_DECL_GETDELIM @@ -921,7 +1031,7 @@ _GL_CXXALIAS_SYS (getline, ssize_t, (char **restrict lineptr, size_t *restrict linesize, FILE *restrict stream)); # endif -# if @HAVE_DECL_GETLINE@ +# if __GLIBC__ >= 2 && @HAVE_DECL_GETLINE@ _GL_CXXALIASWARN (getline); # endif #elif defined GNULIB_POSIXCHECK @@ -951,9 +1061,17 @@ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); # endif _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream)); # else +# if @HAVE_DECL_GETW@ +# if defined __APPLE__ && defined __MACH__ +/* The presence of the declaration depends on _POSIX_C_SOURCE. */ +_GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream)); +# endif _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); +# endif # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getw); +# endif #endif #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ @@ -1052,13 +1170,15 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " # endif _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) - _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) + _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); # else # if !@HAVE_POPEN@ || __GNUC__ >= 11 _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) - _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); # endif @@ -1068,7 +1188,8 @@ _GL_CXXALIASWARN (popen); /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) - _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif # if defined GNULIB_POSIXCHECK # undef popen @@ -1190,9 +1311,17 @@ _GL_CXXALIASWARN (puts); # endif _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream)); # else +# if @HAVE_DECL_PUTW@ +# if defined __APPLE__ && defined __MACH__ +/* The presence of the declaration depends on _POSIX_C_SOURCE. */ +_GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream)); +# endif _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); +# endif # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (putw); +# endif #endif #if @GNULIB_REMOVE@ @@ -1398,13 +1527,15 @@ _GL_CXXALIASWARN (tempnam); # define tmpfile rpl_tmpfile # endif _GL_FUNCDECL_RPL (tmpfile, FILE *, (void) - _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); # else # if __GNUC__ >= 11 /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) - _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); # endif @@ -1415,7 +1546,8 @@ _GL_CXXALIASWARN (tmpfile); # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) - _GL_ATTRIBUTE_DEALLOC (fclose, 1)); + _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); # endif # if defined GNULIB_POSIXCHECK # undef tmpfile diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h index b79e5f7..e74e7c1 100644 --- a/gl/stdlib.in.h +++ b/gl/stdlib.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 1995, 2001-2004, 2006-2023 Free Software Foundation, Inc. + Copyright (C) 1995, 2001-2004, 2006-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -37,6 +37,13 @@ #ifndef _@GUARD_PREFIX@_STDLIB_H #define _@GUARD_PREFIX@_STDLIB_H +/* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* NetBSD 5.0 mis-defines NULL. */ #include @@ -67,9 +74,7 @@ # include # endif -# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@ -# include -# endif +# include # if !@HAVE_STRUCT_RANDOM_DATA@ /* Define 'struct random_data'. @@ -128,6 +133,28 @@ struct random_data # endif #endif +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + /* The __attribute__ feature is available in gcc versions 2.5 and later. The attribute __pure__ was added in gcc 2.96. */ #ifndef _GL_ATTRIBUTE_PURE @@ -164,11 +191,22 @@ struct random_data #if @GNULIB__EXIT@ /* Terminate the current process with the given return code, without running the 'atexit' handlers. */ -# if !@HAVE__EXIT@ +# if @REPLACE__EXIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef _Exit +# define _Exit rpl__Exit +# endif +_GL_FUNCDECL_RPL (_Exit, _Noreturn void, (int status)); +_GL_CXXALIAS_RPL (_Exit, void, (int status)); +# else +# if !@HAVE__EXIT@ _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status)); -# endif +# endif _GL_CXXALIAS_SYS (_Exit, void, (int status)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (_Exit); +# endif #elif defined GNULIB_POSIXCHECK # undef _Exit # if HAVE_RAW_DECL__EXIT @@ -185,7 +223,7 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - " # define free rpl_free # endif # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) -_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ()); +_GL_FUNCDECL_RPL (free, void, (void *ptr) _GL_ATTRIBUTE_NOTHROW); # else _GL_FUNCDECL_RPL (free, void, (void *ptr)); # endif @@ -219,9 +257,16 @@ _GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size)); # if @HAVE_ALIGNED_ALLOC@ # if __GNUC__ >= 11 /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 +_GL_FUNCDECL_SYS (aligned_alloc, void *, + (size_t alignment, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else _GL_FUNCDECL_SYS (aligned_alloc, void *, (size_t alignment, size_t size) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size)); # endif @@ -232,9 +277,16 @@ _GL_CXXALIASWARN (aligned_alloc); #else # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 _GL_FUNCDECL_SYS (aligned_alloc, void *, (size_t alignment, size_t size) + _GL_ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (aligned_alloc, void *, + (size_t alignment, size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif # if defined GNULIB_POSIXCHECK # undef aligned_alloc @@ -277,9 +329,16 @@ _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); # else # if __GNUC__ >= 11 /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (calloc, void *, (size_t nmemb, size_t size) + _GL_ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (calloc, void *, + (size_t nmemb, size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); # endif @@ -289,9 +348,16 @@ _GL_CXXALIASWARN (calloc); #else # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (calloc, void *, + (size_t nmemb, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else _GL_FUNCDECL_SYS (calloc, void *, (size_t nmemb, size_t size) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif # if defined GNULIB_POSIXCHECK # undef calloc @@ -313,10 +379,18 @@ _GL_FUNCDECL_RPL (canonicalize_file_name, char *, _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); # else # if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) + _GL_ATTRIBUTE_NOTHROW _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (canonicalize_file_name, char *, + (const char *name) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); # endif @@ -329,10 +403,18 @@ _GL_CXXALIASWARN (canonicalize_file_name); # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name /* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) + _GL_ATTRIBUTE_NOTHROW _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (canonicalize_file_name, char *, + (const char *name) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif # if defined GNULIB_POSIXCHECK # undef canonicalize_file_name @@ -416,12 +498,24 @@ _GL_CXXALIASWARN (gcvt); The three numbers are the load average of the last 1 minute, the last 5 minutes, and the last 15 minutes, respectively. LOADAVG is an array of NELEM numbers. */ -# if !@HAVE_DECL_GETLOADAVG@ +# if @REPLACE_GETLOADAVG@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getloadavg +# define getloadavg rpl_getloadavg +# endif +_GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (getloadavg, int, (double loadavg[], int nelem)); +# else +# if !@HAVE_DECL_GETLOADAVG@ _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getloadavg); +# endif #elif defined GNULIB_POSIXCHECK # undef getloadavg # if HAVE_RAW_DECL_GETLOADAVG @@ -430,6 +524,41 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " # endif #endif +#if @GNULIB_GETPROGNAME@ +/* Return the base name of the executing program. + On native Windows this will usually end in ".exe" or ".EXE". */ +# if @REPLACE_GETPROGNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getprogname +# define getprogname rpl_getprogname +# endif +# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ +_GL_FUNCDECL_RPL (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); +# else +_GL_FUNCDECL_RPL (getprogname, const char *, (void)); +# endif +_GL_CXXALIAS_RPL (getprogname, const char *, (void)); +# else +# if !@HAVE_GETPROGNAME@ +# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ +_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); +# else +_GL_FUNCDECL_SYS (getprogname, const char *, (void)); +# endif +# endif +_GL_CXXALIAS_SYS (getprogname, const char *, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getprogname); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getprogname +# if HAVE_RAW_DECL_GETPROGNAME +_GL_WARN_ON_USE (getprogname, "getprogname is unportable - " + "use gnulib module getprogname for portability"); +# endif +#endif + #if @GNULIB_GETSUBOPT@ /* Assuming *OPTIONP is a comma separated list of elements of the form "token" or "token=value", getsubopt parses the first of these elements. @@ -442,14 +571,28 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. For more details see the POSIX specification. https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */ -# if !@HAVE_GETSUBOPT@ +# if @REPLACE_GETSUBOPT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getsubopt +# define getsubopt rpl_getsubopt +# endif +_GL_FUNCDECL_RPL (getsubopt, int, + (char **optionp, char *const *tokens, char **valuep) + _GL_ARG_NONNULL ((1, 2, 3))); +_GL_CXXALIAS_RPL (getsubopt, int, + (char **optionp, char *const *tokens, char **valuep)); +# else +# if !@HAVE_GETSUBOPT@ _GL_FUNCDECL_SYS (getsubopt, int, (char **optionp, char *const *tokens, char **valuep) _GL_ARG_NONNULL ((1, 2, 3))); -# endif +# endif _GL_CXXALIAS_SYS (getsubopt, int, (char **optionp, char *const *tokens, char **valuep)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getsubopt); +# endif #elif defined GNULIB_POSIXCHECK # undef getsubopt # if HAVE_RAW_DECL_GETSUBOPT @@ -493,9 +636,16 @@ _GL_CXXALIAS_RPL (malloc, void *, (size_t size)); # else # if __GNUC__ >= 11 /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 _GL_FUNCDECL_SYS (malloc, void *, (size_t size) + _GL_ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (malloc, void *, + (size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); # endif @@ -505,9 +655,16 @@ _GL_CXXALIASWARN (malloc); #else # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (malloc, void *, + (size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else _GL_FUNCDECL_SYS (malloc, void *, (size_t size) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC # undef malloc @@ -517,6 +674,51 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " # endif #endif +/* Return maximum number of bytes of a multibyte character. */ +#if @REPLACE_MB_CUR_MAX@ +# if !GNULIB_defined_MB_CUR_MAX +static inline +int gl_MB_CUR_MAX (void) +{ + /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */ + return MB_CUR_MAX + (MB_CUR_MAX == 3); +} +# undef MB_CUR_MAX +# define MB_CUR_MAX gl_MB_CUR_MAX () +# define GNULIB_defined_MB_CUR_MAX 1 +# endif +#endif + +/* Convert a string to a wide string. */ +#if @GNULIB_MBSTOWCS@ +# if @REPLACE_MBSTOWCS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbstowcs +# define mbstowcs rpl_mbstowcs +# endif +_GL_FUNCDECL_RPL (mbstowcs, size_t, + (wchar_t *restrict dest, const char *restrict src, + size_t len) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (mbstowcs, size_t, + (wchar_t *restrict dest, const char *restrict src, + size_t len)); +# else +_GL_CXXALIAS_SYS (mbstowcs, size_t, + (wchar_t *restrict dest, const char *restrict src, + size_t len)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbstowcs); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbstowcs +# if HAVE_RAW_DECL_MBSTOWCS +_GL_WARN_ON_USE (mbstowcs, "mbstowcs is unportable - " + "use gnulib module mbstowcs for portability"); +# endif +#endif + /* Convert a multibyte character to a wide character. */ #if @GNULIB_MBTOWC@ # if @REPLACE_MBTOWC@ @@ -579,12 +781,24 @@ _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " implementation. Returns the open file descriptor if successful, otherwise -1 and errno set. */ -# if !@HAVE_MKOSTEMP@ +# if @REPLACE_MKOSTEMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mkostemp +# define mkostemp rpl_mkostemp +# endif +_GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mkostemp, int, (char * /*template*/, int /*flags*/)); +# else +# if !@HAVE_MKOSTEMP@ _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (mkostemp); +# endif #elif defined GNULIB_POSIXCHECK # undef mkostemp # if HAVE_RAW_DECL_MKOSTEMP @@ -607,14 +821,28 @@ _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " implementation. Returns the open file descriptor if successful, otherwise -1 and errno set. */ -# if !@HAVE_MKOSTEMPS@ +# if @REPLACE_MKOSTEMPS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mkostemps +# define mkostemps rpl_mkostemps +# endif +_GL_FUNCDECL_RPL (mkostemps, int, + (char * /*template*/, int /*suffixlen*/, int /*flags*/) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mkostemps, int, + (char * /*template*/, int /*suffixlen*/, int /*flags*/)); +# else +# if !@HAVE_MKOSTEMPS@ _GL_FUNCDECL_SYS (mkostemps, int, (char * /*template*/, int /*suffixlen*/, int /*flags*/) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (mkostemps, int, (char * /*template*/, int /*suffixlen*/, int /*flags*/)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (mkostemps); +# endif #elif defined GNULIB_POSIXCHECK # undef mkostemps # if HAVE_RAW_DECL_MKOSTEMPS @@ -713,7 +941,7 @@ _GL_CXXALIAS_SYS (posix_memalign, int, (void **memptr, size_t alignment, size_t size)); # endif # endif -# if @HAVE_POSIX_MEMALIGN@ +# if __GLIBC__ >= 2 && @HAVE_POSIX_MEMALIGN@ _GL_CXXALIASWARN (posix_memalign); # endif #elif defined GNULIB_POSIXCHECK @@ -727,11 +955,22 @@ _GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - " #if @GNULIB_POSIX_OPENPT@ /* Return an FD open to the master side of a pseudo-terminal. Flags should include O_RDWR, and may also include O_NOCTTY. */ -# if !@HAVE_POSIX_OPENPT@ +# if @REPLACE_POSIX_OPENPT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef posix_openpt +# define posix_openpt rpl_posix_openpt +# endif +_GL_FUNCDECL_RPL (posix_openpt, int, (int flags)); +_GL_CXXALIAS_RPL (posix_openpt, int, (int flags)); +# else +# if !@HAVE_POSIX_OPENPT@ _GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); -# endif +# endif _GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (posix_openpt); +# endif #elif defined GNULIB_POSIXCHECK # undef posix_openpt # if HAVE_RAW_DECL_POSIX_OPENPT @@ -808,6 +1047,10 @@ _GL_CXXALIAS_RPL (putenv, int, (char *string)); # define putenv _putenv # endif _GL_CXXALIAS_MDA (putenv, int, (char *string)); +# elif defined __KLIBC__ +/* Need to cast, because on OS/2 kLIBC, the first parameter is + const char *string. */ +_GL_CXXALIAS_SYS_CAST (putenv, int, (char *string)); # else _GL_CXXALIAS_SYS (putenv, int, (char *string)); # endif @@ -824,6 +1067,10 @@ _GL_CXXALIASWARN (putenv); /* Need to cast, because on mingw, the parameter is either 'const char *string' or 'char *string'. */ _GL_CXXALIAS_MDA_CAST (putenv, int, (char *string)); +# elif defined __KLIBC__ +/* Need to cast, because on OS/2 kLIBC, the first parameter is + const char *string. */ +_GL_CXXALIAS_SYS_CAST (putenv, int, (char *string)); # else _GL_CXXALIAS_SYS (putenv, int, (char *string)); # endif @@ -865,7 +1112,9 @@ _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, _gl_qsort_r_compar_fn compare, void *arg)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (qsort_r); +# endif #elif defined GNULIB_POSIXCHECK # undef qsort_r # if HAVE_RAW_DECL_QSORT_R @@ -875,11 +1124,26 @@ _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - " #endif -#if @GNULIB_RANDOM_R@ -# if !@HAVE_RANDOM_R@ -# ifndef RAND_MAX -# define RAND_MAX 2147483647 +#if @GNULIB_RAND@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) +# ifndef RAND_MAX +# define RAND_MAX 2147483647 +# endif +#endif + + +#if @GNULIB_RAND@ +# if @REPLACE_RAND@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rand +# define rand rpl_rand # endif +_GL_FUNCDECL_RPL (rand, int, (void)); +_GL_CXXALIAS_RPL (rand, int, (void)); +# else +_GL_CXXALIAS_SYS (rand, int, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (rand); # endif #endif @@ -900,7 +1164,9 @@ _GL_FUNCDECL_SYS (random, long, (void)); int. */ _GL_CXXALIAS_SYS_CAST (random, long, (void)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (random); +# endif #elif defined GNULIB_POSIXCHECK # undef random # if HAVE_RAW_DECL_RANDOM @@ -925,7 +1191,9 @@ _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); unsigned long seed. */ _GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (srandom); +# endif #elif defined GNULIB_POSIXCHECK # undef srandom # if HAVE_RAW_DECL_SRANDOM @@ -956,7 +1224,9 @@ _GL_FUNCDECL_SYS (initstate, char *, _GL_CXXALIAS_SYS_CAST (initstate, char *, (unsigned int seed, char *buf, size_t buf_size)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (initstate); +# endif #elif defined GNULIB_POSIXCHECK # undef initstate # if HAVE_RAW_DECL_INITSTATE @@ -981,7 +1251,9 @@ _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); is const char *arg_state. */ _GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (setstate); +# endif #elif defined GNULIB_POSIXCHECK # undef setstate # if HAVE_RAW_DECL_SETSTATE @@ -1126,8 +1398,16 @@ _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); # else # if __GNUC__ >= 11 /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ -_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size) - _GL_ATTRIBUTE_DEALLOC_FREE); +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (realloc, void *, + (void *ptr, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (realloc, void *, + (void *ptr, size_t size) + _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); # endif @@ -1137,8 +1417,16 @@ _GL_CXXALIASWARN (realloc); #else # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ -_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size) - _GL_ATTRIBUTE_DEALLOC_FREE); +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (realloc, void *, + (void *ptr, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (realloc, void *, + (void *ptr, size_t size) + _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC # undef realloc @@ -1167,7 +1455,9 @@ _GL_FUNCDECL_SYS (reallocarray, void *, _GL_CXXALIAS_SYS (reallocarray, void *, (void *ptr, size_t nmemb, size_t size)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (reallocarray); +# endif #elif defined GNULIB_POSIXCHECK # undef reallocarray # if HAVE_RAW_DECL_REALLOCARRAY @@ -1301,6 +1591,38 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - " # endif #endif +#if @GNULIB_STRTOF@ + /* Parse a float from STRING, updating ENDP if appropriate. */ +# if @REPLACE_STRTOF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strtof rpl_strtof +# endif +# define GNULIB_defined_strtof_function 1 +_GL_FUNCDECL_RPL (strtof, float, + (const char *restrict str, char **restrict endp) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strtof, float, + (const char *restrict str, char **restrict endp)); +# else +# if !@HAVE_STRTOF@ +_GL_FUNCDECL_SYS (strtof, float, + (const char *restrict str, char **restrict endp) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strtof, float, + (const char *restrict str, char **restrict endp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (strtof); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strtof +# if HAVE_RAW_DECL_STRTOF +_GL_WARN_ON_USE (strtof, "strtof is unportable - " + "use gnulib module strtof for portability"); +# endif +#endif + #if @GNULIB_STRTOLD@ /* Parse a 'long double' from STRING, updating ENDP if appropriate. */ # if @REPLACE_STRTOLD@ diff --git a/gl/str-two-way.h b/gl/str-two-way.h index dfe7022..cf85e26 100644 --- a/gl/str-two-way.h +++ b/gl/str-two-way.h @@ -1,5 +1,5 @@ /* Byte-wise substring search, using the Two-Way algorithm. - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Eric Blake , 2008. diff --git a/gl/strcasecmp.c b/gl/strcasecmp.c index 3a5ce3e..7939b40 100644 --- a/gl/strcasecmp.c +++ b/gl/strcasecmp.c @@ -1,5 +1,5 @@ /* Case-insensitive string comparison function. - Copyright (C) 1998-1999, 2005-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -22,8 +22,6 @@ #include #include -#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) - /* Compare strings S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. @@ -41,8 +39,8 @@ strcasecmp (const char *s1, const char *s2) do { - c1 = TOLOWER (*p1); - c2 = TOLOWER (*p2); + c1 = tolower (*p1); + c2 = tolower (*p2); if (c1 == '\0') break; diff --git a/gl/strcasestr.c b/gl/strcasestr.c index 8eea435..b8c0479 100644 --- a/gl/strcasestr.c +++ b/gl/strcasestr.c @@ -1,5 +1,5 @@ /* Case-insensitive searching in a string. - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2005. This file is free software: you can redistribute it and/or modify @@ -23,14 +23,12 @@ #include #include -#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) - /* Two-Way algorithm. */ #define RETURN_TYPE char * #define AVAILABLE(h, h_l, j, n_l) \ (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ && ((h_l) = (j) + (n_l))) -#define CANON_ELEMENT(c) TOLOWER (c) +#define CANON_ELEMENT(c) tolower (c) #define CMP_FUNC(p1, p2, l) \ strncasecmp ((const char *) (p1), (const char *) (p2), l) #include "str-two-way.h" @@ -52,8 +50,8 @@ strcasestr (const char *haystack_start, const char *needle_start) NEEDLE if HAYSTACK is too short). */ while (*haystack && *needle) { - ok &= (TOLOWER ((unsigned char) *haystack) - == TOLOWER ((unsigned char) *needle)); + ok &= (tolower ((unsigned char) *haystack) + == tolower ((unsigned char) *needle)); haystack++; needle++; } diff --git a/gl/streq.h b/gl/streq.h index 712948e..8593de6 100644 --- a/gl/streq.h +++ b/gl/streq.h @@ -1,5 +1,5 @@ /* Optimized string comparison. - Copyright (C) 2001-2002, 2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -21,6 +21,11 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + + /* STREQ_OPT allows to optimize string comparison with a small literal string. STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) is semantically equivalent to @@ -173,4 +178,9 @@ streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, #endif + +#ifdef __cplusplus +} +#endif + #endif /* _GL_STREQ_H */ diff --git a/gl/strerror-override.c b/gl/strerror-override.c index cddaa4a..b9c1c7a 100644 --- a/gl/strerror-override.c +++ b/gl/strerror-override.c @@ -1,6 +1,6 @@ /* strerror-override.c --- POSIX compatible system error routine - Copyright (C) 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2010-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/strerror-override.h b/gl/strerror-override.h index 388cc28..a1734a2 100644 --- a/gl/strerror-override.h +++ b/gl/strerror-override.h @@ -1,6 +1,6 @@ /* strerror-override.h --- POSIX compatible system error routine - Copyright (C) 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2010-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -16,42 +16,57 @@ along with this program. If not, see . */ #ifndef _GL_STRERROR_OVERRIDE_H -# define _GL_STRERROR_OVERRIDE_H +#define _GL_STRERROR_OVERRIDE_H + +/* This file uses _GL_ATTRIBUTE_CONST. */ +#if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif -# include -# include /* Reasonable buffer size that should never trigger ERANGE; if this proves too small, we intentionally abort(), to remind us to fix this value. */ -# define STACKBUF_LEN 256 +#define STACKBUF_LEN 256 /* If ERRNUM maps to an errno value defined by gnulib, return a string describing the error. Otherwise return NULL. */ -# if REPLACE_STRERROR_0 \ - || GNULIB_defined_ESOCK \ - || GNULIB_defined_ESTREAMS \ - || GNULIB_defined_EWINSOCK \ - || GNULIB_defined_ENOMSG \ - || GNULIB_defined_EIDRM \ - || GNULIB_defined_ENOLINK \ - || GNULIB_defined_EPROTO \ - || GNULIB_defined_EMULTIHOP \ - || GNULIB_defined_EBADMSG \ - || GNULIB_defined_EOVERFLOW \ - || GNULIB_defined_ENOTSUP \ - || GNULIB_defined_ENETRESET \ - || GNULIB_defined_ECONNABORTED \ - || GNULIB_defined_ESTALE \ - || GNULIB_defined_EDQUOT \ - || GNULIB_defined_ECANCELED \ - || GNULIB_defined_EOWNERDEAD \ - || GNULIB_defined_ENOTRECOVERABLE \ - || GNULIB_defined_EILSEQ +#if REPLACE_STRERROR_0 \ + || GNULIB_defined_ESOCK \ + || GNULIB_defined_ESTREAMS \ + || GNULIB_defined_EWINSOCK \ + || GNULIB_defined_ENOMSG \ + || GNULIB_defined_EIDRM \ + || GNULIB_defined_ENOLINK \ + || GNULIB_defined_EPROTO \ + || GNULIB_defined_EMULTIHOP \ + || GNULIB_defined_EBADMSG \ + || GNULIB_defined_EOVERFLOW \ + || GNULIB_defined_ENOTSUP \ + || GNULIB_defined_ENETRESET \ + || GNULIB_defined_ECONNABORTED \ + || GNULIB_defined_ESTALE \ + || GNULIB_defined_EDQUOT \ + || GNULIB_defined_ECANCELED \ + || GNULIB_defined_EOWNERDEAD \ + || GNULIB_defined_ENOTRECOVERABLE \ + || GNULIB_defined_EILSEQ extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST; -# else -# define strerror_override(ignored) NULL -# define GNULIB_defined_strerror_override_macro 1 -# endif +#else +# define strerror_override(ignored) NULL +# define GNULIB_defined_strerror_override_macro 1 +#endif + + +#ifdef __cplusplus +} +#endif #endif /* _GL_STRERROR_OVERRIDE_H */ diff --git a/gl/strerror.c b/gl/strerror.c index d754f60..6b760ff 100644 --- a/gl/strerror.c +++ b/gl/strerror.c @@ -1,6 +1,6 @@ /* strerror.c --- POSIX compatible system error routine - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/string.in.h b/gl/string.in.h index e993b2f..44ec2e7 100644 --- a/gl/string.in.h +++ b/gl/string.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 1995-1996, 2001-2023 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 2001-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -44,6 +44,13 @@ #ifndef _@GUARD_PREFIX@_STRING_H #define _@GUARD_PREFIX@_STRING_H +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* NetBSD 5.0 mis-defines NULL. */ #include @@ -59,10 +66,11 @@ # include #endif -/* AIX 7.2 declares ffsl and ffsll in , not in . */ +/* AIX 7.2 and Android 13 declare ffsl and ffsll in , not in + . */ /* But in any case avoid namespace pollution on glibc systems. */ #if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \ - && defined _AIX) \ + && (defined _AIX || defined __ANDROID__)) \ && ! defined __GLIBC__ # include #endif @@ -103,6 +111,28 @@ # endif #endif +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + /* The __attribute__ feature is available in gcc versions 2.5 and later. The attribute __pure__ was added in gcc 2.96. */ #ifndef _GL_ATTRIBUTE_PURE @@ -125,7 +155,11 @@ # if (@REPLACE_FREE@ && !defined free \ && !(defined __cplusplus && defined GNULIB_NAMESPACE)) /* We can't do '#define free rpl_free' here. */ +# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) +_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW; +# else _GL_EXTERN_C void rpl_free (void *); +# endif # undef _GL_ATTRIBUTE_DEALLOC_FREE # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) # else @@ -137,7 +171,7 @@ _GL_EXTERN_C void __cdecl free (void *); # else # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) -_GL_EXTERN_C void free (void *) throw (); +_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; # else _GL_EXTERN_C void free (void *); # endif @@ -152,7 +186,7 @@ _GL_EXTERN_C void __cdecl free (void *); # else # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) -_GL_EXTERN_C void free (void *) throw (); +_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; # else _GL_EXTERN_C void free (void *); # endif @@ -255,9 +289,12 @@ _GL_CXXALIAS_SYS_CAST2 (memchr, # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ || defined __clang__) -_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ()); +_GL_CXXALIASWARN1 (memchr, void *, + (void *__s, int __c, size_t __n) + _GL_ATTRIBUTE_NOTHROW); _GL_CXXALIASWARN1 (memchr, void const *, - (void const *__s, int __c, size_t __n) throw ()); + (void const *__s, int __c, size_t __n) + _GL_ATTRIBUTE_NOTHROW); # elif __GLIBC__ >= 2 _GL_CXXALIASWARN (memchr); # endif @@ -307,16 +344,32 @@ _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " /* Copy N bytes of SRC to DEST, return pointer to bytes after the last written byte. */ #if @GNULIB_MEMPCPY@ -# if ! @HAVE_MEMPCPY@ +# if @REPLACE_MEMPCPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mempcpy +# define mempcpy rpl_mempcpy +# endif +_GL_FUNCDECL_RPL (mempcpy, void *, + (void *restrict __dest, void const *restrict __src, + size_t __n) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (mempcpy, void *, + (void *restrict __dest, void const *restrict __src, + size_t __n)); +# else +# if !@HAVE_MEMPCPY@ _GL_FUNCDECL_SYS (mempcpy, void *, (void *restrict __dest, void const *restrict __src, size_t __n) _GL_ARG_NONNULL ((1, 2))); -# endif +# endif _GL_CXXALIAS_SYS (mempcpy, void *, (void *restrict __dest, void const *restrict __src, size_t __n)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (mempcpy); +# endif #elif defined GNULIB_POSIXCHECK # undef mempcpy # if HAVE_RAW_DECL_MEMPCPY @@ -341,9 +394,13 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr, # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ || defined __clang__) -_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ()); -_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ()); -# else +_GL_CXXALIASWARN1 (memrchr, void *, + (void *, int, size_t) + _GL_ATTRIBUTE_NOTHROW); +_GL_CXXALIASWARN1 (memrchr, void const *, + (void const *, int, size_t) + _GL_ATTRIBUTE_NOTHROW); +# elif __GLIBC__ >= 2 _GL_CXXALIASWARN (memrchr); # endif #elif defined GNULIB_POSIXCHECK @@ -357,11 +414,21 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " /* Overwrite a block of memory. The compiler will not optimize effects away, even if the block is dead after the call. */ #if @GNULIB_MEMSET_EXPLICIT@ -# if ! @HAVE_MEMSET_EXPLICIT@ +# if @REPLACE_MEMSET_EXPLICIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef memset_explicit +# define memset_explicit rpl_memset_explicit +# endif +_GL_FUNCDECL_RPL (memset_explicit, void *, + (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n)); +# else +# if !@HAVE_MEMSET_EXPLICIT@ _GL_FUNCDECL_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n)); +# endif _GL_CXXALIASWARN (memset_explicit); #elif defined GNULIB_POSIXCHECK # undef memset_explicit @@ -389,9 +456,12 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr, # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ || defined __clang__) -_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ()); +_GL_CXXALIASWARN1 (rawmemchr, void *, + (void *__s, int __c_in) + _GL_ATTRIBUTE_NOTHROW); _GL_CXXALIASWARN1 (rawmemchr, void const *, - (void const *__s, int __c_in) throw ()); + (void const *__s, int __c_in) + _GL_ATTRIBUTE_NOTHROW); # else _GL_CXXALIASWARN (rawmemchr); # endif @@ -405,14 +475,28 @@ _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ #if @GNULIB_STPCPY@ -# if ! @HAVE_STPCPY@ +# if @REPLACE_STPCPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef stpcpy +# define stpcpy rpl_stpcpy +# endif +_GL_FUNCDECL_RPL (stpcpy, char *, + (char *restrict __dst, char const *restrict __src) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (stpcpy, char *, + (char *restrict __dst, char const *restrict __src)); +# else +# if !@HAVE_STPCPY@ _GL_FUNCDECL_SYS (stpcpy, char *, (char *restrict __dst, char const *restrict __src) _GL_ARG_NONNULL ((1, 2))); -# endif +# endif _GL_CXXALIAS_SYS (stpcpy, char *, (char *restrict __dst, char const *restrict __src)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (stpcpy); +# endif #elif defined GNULIB_POSIXCHECK # undef stpcpy # if HAVE_RAW_DECL_STPCPY @@ -447,7 +531,9 @@ _GL_CXXALIAS_SYS (stpncpy, char *, (char *restrict __dst, char const *restrict __src, size_t __n)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (stpncpy); +# endif #elif defined GNULIB_POSIXCHECK # undef stpncpy # if HAVE_RAW_DECL_STPNCPY @@ -495,10 +581,13 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul, # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ || defined __clang__) -_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ()); +_GL_CXXALIASWARN1 (strchrnul, char *, + (char *__s, int __c_in) + _GL_ATTRIBUTE_NOTHROW); _GL_CXXALIASWARN1 (strchrnul, char const *, - (char const *__s, int __c_in) throw ()); -# else + (char const *__s, int __c_in) + _GL_ATTRIBUTE_NOTHROW); +# elif __GLIBC__ >= 2 _GL_CXXALIASWARN (strchrnul); # endif #elif defined GNULIB_POSIXCHECK @@ -533,10 +622,18 @@ _GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); # undef strdup # endif # if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (strdup, char *, + (char const *__s) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); # endif @@ -544,10 +641,18 @@ _GL_CXXALIASWARN (strdup); #else # if __GNUC__ >= 11 && !defined strdup /* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) + _GL_ATTRIBUTE_NOTHROW _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (strdup, char *, + (char const *__s) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif # if defined GNULIB_POSIXCHECK # undef strdup @@ -616,10 +721,18 @@ _GL_FUNCDECL_RPL (strndup, char *, _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); # else # if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup) +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n) + _GL_ATTRIBUTE_NOTHROW _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (strndup, char *, + (char const *__s, size_t __n) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif _GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); # endif @@ -627,10 +740,18 @@ _GL_CXXALIASWARN (strndup); #else # if __GNUC__ >= 11 && !defined strndup /* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n) + _GL_ATTRIBUTE_NOTHROW _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (strndup, char *, + (char const *__s, size_t __n) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif # if defined GNULIB_POSIXCHECK # undef strndup @@ -699,9 +820,12 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk, # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ || defined __clang__) -_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ()); +_GL_CXXALIASWARN1 (strpbrk, char *, + (char *__s, char const *__accept) + _GL_ATTRIBUTE_NOTHROW); _GL_CXXALIASWARN1 (strpbrk, char const *, - (char const *__s, char const *__accept) throw ()); + (char const *__s, char const *__accept) + _GL_ATTRIBUTE_NOTHROW); # elif __GLIBC__ >= 2 _GL_CXXALIASWARN (strpbrk); # endif @@ -809,9 +933,11 @@ _GL_CXXALIAS_SYS_CAST2 (strstr, && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ || defined __clang__) _GL_CXXALIASWARN1 (strstr, char *, - (char *haystack, const char *needle) throw ()); + (char *haystack, const char *needle) + _GL_ATTRIBUTE_NOTHROW); _GL_CXXALIASWARN1 (strstr, const char *, - (const char *haystack, const char *needle) throw ()); + (const char *haystack, const char *needle) + _GL_ATTRIBUTE_NOTHROW); # elif __GLIBC__ >= 2 _GL_CXXALIASWARN (strstr); # endif @@ -860,10 +986,12 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr, && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ || defined __clang__) _GL_CXXALIASWARN1 (strcasestr, char *, - (char *haystack, const char *needle) throw ()); + (char *haystack, const char *needle) + _GL_ATTRIBUTE_NOTHROW); _GL_CXXALIASWARN1 (strcasestr, const char *, - (const char *haystack, const char *needle) throw ()); -# else + (const char *haystack, const char *needle) + _GL_ATTRIBUTE_NOTHROW); +# elif __GLIBC__ >= 2 _GL_CXXALIASWARN (strcasestr); # endif #elif defined GNULIB_POSIXCHECK @@ -1211,7 +1339,7 @@ _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) # endif _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); # endif -# if @HAVE_DECL_STRERROR_R@ +# if __GLIBC__ >= 2 && @HAVE_DECL_STRERROR_R@ _GL_CXXALIASWARN (strerror_r); # endif #elif defined GNULIB_POSIXCHECK @@ -1301,12 +1429,22 @@ _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " #endif #if @GNULIB_STRVERSCMP@ -# if !@HAVE_STRVERSCMP@ +# if @REPLACE_STRVERSCMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strverscmp rpl_strverscmp +# endif +_GL_FUNCDECL_RPL (strverscmp, int, (const char *, const char *) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (strverscmp, int, (const char *, const char *)); +# else +# if !@HAVE_STRVERSCMP@ _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); -# endif +# endif _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); +# endif _GL_CXXALIASWARN (strverscmp); #elif defined GNULIB_POSIXCHECK # undef strverscmp diff --git a/gl/strings.in.h b/gl/strings.in.h index 2cfe8b1..2b3e062 100644 --- a/gl/strings.in.h +++ b/gl/strings.in.h @@ -1,6 +1,6 @@ /* A substitute . - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -36,6 +36,11 @@ #ifndef _@GUARD_PREFIX@_STRINGS_H #define _@GUARD_PREFIX@_STRINGS_H +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #if ! @HAVE_DECL_STRNCASECMP@ /* Get size_t. */ # include diff --git a/gl/stripslash.c b/gl/stripslash.c index fe46a9c..c127ce7 100644 --- a/gl/stripslash.c +++ b/gl/stripslash.c @@ -1,6 +1,6 @@ /* stripslash.c -- remove redundant trailing slashes from a file name - Copyright (C) 1990, 2001, 2003-2006, 2009-2023 Free Software Foundation, + Copyright (C) 1990, 2001, 2003-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify diff --git a/gl/strncasecmp.c b/gl/strncasecmp.c index c5c2cd3..c79161f 100644 --- a/gl/strncasecmp.c +++ b/gl/strncasecmp.c @@ -1,5 +1,5 @@ /* strncasecmp.c -- case insensitive string comparator - Copyright (C) 1998-1999, 2005-2007, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -22,8 +22,6 @@ #include #include -#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) - /* Compare no more than N bytes of strings S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. @@ -41,8 +39,8 @@ strncasecmp (const char *s1, const char *s2, size_t n) do { - c1 = TOLOWER (*p1); - c2 = TOLOWER (*p2); + c1 = tolower (*p1); + c2 = tolower (*p2); if (--n == 0 || c1 == '\0') break; diff --git a/gl/strsep.c b/gl/strsep.c index 8e9708a..eefd85e 100644 --- a/gl/strsep.c +++ b/gl/strsep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2007, 2009-2023 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2007, 2009-2024 Free Software Foundation, Inc. Written by Yoann Vandoorselaere . diff --git a/gl/strstr.c b/gl/strstr.c index 574f4d5..7ea2860 100644 --- a/gl/strstr.c +++ b/gl/strstr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2023 Free Software +/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/gl/sys-limits.h b/gl/sys-limits.h index 0e9556d..d2f29d8 100644 --- a/gl/sys-limits.h +++ b/gl/sys-limits.h @@ -1,6 +1,6 @@ /* System call limits - Copyright 2018-2023 Free Software Foundation, Inc. + Copyright 2018-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/sys_socket.c b/gl/sys_socket.c index b7388ce..672d3aa 100644 --- a/gl/sys_socket.c +++ b/gl/sys_socket.c @@ -1,6 +1,6 @@ /* Inline functions for . - Copyright (C) 2012-2023 Free Software Foundation, Inc. + Copyright (C) 2012-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,5 +18,5 @@ #include #define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE -#include "sys/socket.h" +#include typedef int dummy; diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h index 6705593..13833c0 100644 --- a/gl/sys_socket.in.h +++ b/gl/sys_socket.in.h @@ -1,6 +1,6 @@ /* Provide a sys/socket header file for systems lacking it (read: MinGW) and for systems where it is incomplete. - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. Written by Simon Josefsson. This file is free software: you can redistribute it and/or modify @@ -63,9 +63,12 @@ #ifndef _@GUARD_PREFIX@_SYS_SOCKET_H #define _@GUARD_PREFIX@_SYS_SOCKET_H -#ifndef _GL_INLINE_HEADER_BEGIN +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*, alignof. */ +#if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif + _GL_INLINE_HEADER_BEGIN #ifndef _GL_SYS_SOCKET_INLINE # define _GL_SYS_SOCKET_INLINE _GL_INLINE @@ -355,7 +358,9 @@ _GL_CXXALIAS_SYS_CAST (accept, int, struct sockaddr *restrict addr, socklen_t *restrict addrlen)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (accept); +# endif #elif @HAVE_WINSOCK2_H@ # undef accept # define accept accept_used_without_requesting_gnulib_module_accept @@ -417,7 +422,9 @@ _GL_CXXALIAS_SYS_CAST (getpeername, int, (int fd, struct sockaddr *restrict addr, socklen_t *restrict addrlen)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getpeername); +# endif #elif @HAVE_WINSOCK2_H@ # undef getpeername # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername @@ -449,7 +456,9 @@ _GL_CXXALIAS_SYS_CAST (getsockname, int, (int fd, struct sockaddr *restrict addr, socklen_t *restrict addrlen)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getsockname); +# endif #elif @HAVE_WINSOCK2_H@ # undef getsockname # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname @@ -596,7 +605,9 @@ _GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t, struct sockaddr *restrict from, socklen_t *restrict fromlen)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (recvfrom); +# endif #elif @HAVE_WINSOCK2_H@ # undef recvfrom # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h index 096887c..bf08f33 100644 --- a/gl/sys_stat.in.h +++ b/gl/sys_stat.in.h @@ -1,5 +1,5 @@ /* Provide a more complete sys/stat.h header file. - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -25,6 +25,13 @@ #endif @PRAGMA_COLUMNS@ +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #if defined __need_system_sys_stat_h /* Special invocation convention. */ @@ -48,12 +55,41 @@ #ifndef _@GUARD_PREFIX@_SYS_STAT_H #define _@GUARD_PREFIX@_SYS_STAT_H +/* This file uses _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ /* The definition of _GL_WARN_ON_USE is copied here. */ + /* Before doing "#define mknod rpl_mknod" below, we need to include all headers that may declare mknod(). OS/2 kLIBC declares mknod() in , not in . */ @@ -549,7 +585,7 @@ _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2])); # endif _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2])); # endif -# if @HAVE_FUTIMENS@ +# if __GLIBC__ >= 2 && @HAVE_FUTIMENS@ _GL_CXXALIASWARN (futimens); # endif #elif defined GNULIB_POSIXCHECK @@ -563,7 +599,11 @@ _GL_WARN_ON_USE (futimens, "futimens is not portable - " #if @GNULIB_GETUMASK@ # if !@HAVE_GETUMASK@ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (getumask, mode_t, (void) _GL_ATTRIBUTE_NOTHROW); +# else _GL_FUNCDECL_SYS (getumask, mode_t, (void)); +# endif # endif _GL_CXXALIAS_SYS (getumask, mode_t, (void)); # if @HAVE_GETUMASK@ @@ -716,7 +756,9 @@ _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode) # endif _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (mkfifoat); +# endif #elif defined GNULIB_POSIXCHECK # undef mkfifoat # if HAVE_RAW_DECL_MKFIFOAT @@ -773,7 +815,9 @@ _GL_FUNCDECL_SYS (mknodat, int, _GL_CXXALIAS_SYS (mknodat, int, (int fd, char const *file, mode_t mode, dev_t dev)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (mknodat); +# endif #elif defined GNULIB_POSIXCHECK # undef mknodat # if HAVE_RAW_DECL_MKNODAT @@ -937,7 +981,7 @@ _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name, _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name, struct timespec const times[2], int flag)); # endif -# if @HAVE_UTIMENSAT@ +# if __GLIBC__ >= 2 && @HAVE_UTIMENSAT@ _GL_CXXALIASWARN (utimensat); # endif #elif defined GNULIB_POSIXCHECK diff --git a/gl/sys_types.in.h b/gl/sys_types.in.h index 082a6c6..0a0ccc3 100644 --- a/gl/sys_types.in.h +++ b/gl/sys_types.in.h @@ -1,6 +1,6 @@ /* Provide a more complete sys/types.h. - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -20,6 +20,13 @@ #endif @PRAGMA_COLUMNS@ +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #if defined _WIN32 && !defined __CYGWIN__ \ && (defined __need_off_t || defined __need___off64_t \ || defined __need_ssize_t || defined __need_time_t) diff --git a/gl/sys_uio.in.h b/gl/sys_uio.in.h index 64c4fb6..5e71859 100644 --- a/gl/sys_uio.in.h +++ b/gl/sys_uio.in.h @@ -1,5 +1,5 @@ /* Substitute for . - Copyright (C) 2011-2023 Free Software Foundation, Inc. + Copyright (C) 2011-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/time.in.h b/gl/time.in.h index 50c9b30..df99c8a 100644 --- a/gl/time.in.h +++ b/gl/time.in.h @@ -1,6 +1,6 @@ /* A more-standard . - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -20,6 +20,13 @@ #endif @PRAGMA_COLUMNS@ +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Don't get in the way of glibc when it includes time.h merely to declare a few standard symbols, rather than to declare all the symbols. (However, skip this for MinGW as it treats __need_time_t @@ -45,6 +52,12 @@ # @INCLUDE_NEXT@ @NEXT_TIME_H@ +/* This file uses _GL_ATTRIBUTE_DEPRECATED, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + /* NetBSD 5.0 mis-defines NULL. */ # include @@ -112,23 +125,79 @@ struct __time_t_must_be_integral { /* Set *TS to the current time, and return BASE. Upon failure, return 0. */ # if @GNULIB_TIMESPEC_GET@ -# if ! @HAVE_TIMESPEC_GET@ +# if @REPLACE_TIMESPEC_GET@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef timespec_get +# define timespec_get rpl_timespec_get +# endif +_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base)); +# else +# if !@HAVE_TIMESPEC_GET@ _GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (timespec_get); +# endif +# elif defined GNULIB_POSIXCHECK +# undef timespec_get +# if HAVE_RAW_DECL_TIMESPEC_GET +_GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - " + "use gnulib module timespec_get for portability"); +# endif # endif /* Set *TS to the current time resolution, and return BASE. Upon failure, return 0. */ # if @GNULIB_TIMESPEC_GETRES@ -# if ! @HAVE_TIMESPEC_GETRES@ +# if @REPLACE_TIMESPEC_GETRES@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef timespec_getres +# define timespec_getres rpl_timespec_getres +# endif +_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (timespec_getres, int, (struct timespec *ts, int base)); +# else +# if !@HAVE_TIMESPEC_GETRES@ _GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base)); +# endif _GL_CXXALIASWARN (timespec_getres); +# elif defined GNULIB_POSIXCHECK +# undef timespec_getres +# if HAVE_RAW_DECL_TIMESPEC_GETRES +_GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - " + "use gnulib module timespec_getres for portability"); +# endif +# endif + +/* Return the number of seconds that have elapsed since the Epoch. */ +# if @GNULIB_TIME@ +# if @REPLACE_TIME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define time rpl_time +# endif +_GL_FUNCDECL_RPL (time, time_t, (time_t *__tp)); +_GL_CXXALIAS_RPL (time, time_t, (time_t *__tp)); +# else +_GL_CXXALIAS_SYS (time, time_t, (time_t *__tp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (time); +# endif +# elif defined GNULIB_POSIXCHECK +# undef time +# if HAVE_RAW_DECL_TIME +_GL_WARN_ON_USE (time, "time has consistency problems - " + "use gnulib module time for portability"); +# endif # endif /* Sleep for at least RQTP seconds unless interrupted, If interrupted, @@ -154,6 +223,12 @@ _GL_CXXALIAS_SYS (nanosleep, int, (struct timespec const *__rqtp, struct timespec *__rmtp)); # endif _GL_CXXALIASWARN (nanosleep); +# elif defined GNULIB_POSIXCHECK +# undef nanosleep +# if HAVE_RAW_DECL_NANOSLEEP +_GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - " + "use gnulib module nanosleep for portability"); +# endif # endif /* Initialize time conversion information. */ @@ -189,6 +264,12 @@ _GL_CXXALIAS_MDA (tzset, void, (void)); _GL_CXXALIAS_SYS (tzset, void, (void)); # endif _GL_CXXALIASWARN (tzset); +# elif defined GNULIB_POSIXCHECK +# undef tzset +# if HAVE_RAW_DECL_TZSET +_GL_WARN_ON_USE (tzset, "tzset has portability problems - " + "use gnulib module tzset for portability"); +# endif # endif /* Return the 'time_t' representation of TP and normalize TP. */ @@ -205,6 +286,12 @@ _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); # if __GLIBC__ >= 2 _GL_CXXALIASWARN (mktime); # endif +# elif defined GNULIB_POSIXCHECK +# undef mktime +# if HAVE_RAW_DECL_MKTIME +_GL_WARN_ON_USE (mktime, "mktime has portability problems - " + "use gnulib module mktime for portability"); +# endif # endif /* Convert TIMER to RESULT, assuming local time and UTC respectively. See @@ -255,6 +342,17 @@ _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, # if @HAVE_DECL_LOCALTIME_R@ _GL_CXXALIASWARN (gmtime_r); # endif +# elif defined GNULIB_POSIXCHECK +# undef localtime_r +# if HAVE_RAW_DECL_LOCALTIME_R +_GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - " + "use gnulib module time_r for portability"); +# endif +# undef gmtime_r +# if HAVE_RAW_DECL_GMTIME_R +_GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - " + "use gnulib module time_r for portability"); +# endif # endif /* Convert TIMER to RESULT, assuming local time and UTC respectively. See @@ -275,6 +373,12 @@ _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); # if __GLIBC__ >= 2 _GL_CXXALIASWARN (localtime); # endif +# elif defined GNULIB_POSIXCHECK +# undef localtime +# if HAVE_RAW_DECL_LOCALTIME +_GL_WARN_ON_USE (localtime, "localtime has portability problems - " + "use gnulib module localtime for portability"); +# endif # endif # if 0 || @REPLACE_GMTIME@ @@ -306,6 +410,12 @@ _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, char const *restrict __format, struct tm *restrict __tm)); _GL_CXXALIASWARN (strptime); +# elif defined GNULIB_POSIXCHECK +# undef strptime +# if HAVE_RAW_DECL_STRPTIME +_GL_WARN_ON_USE (strptime, "strptime is unportable - " + "use gnulib module strptime for portability"); +# endif # endif /* Convert *TP to a date and time string. See @@ -315,7 +425,9 @@ _GL_CXXALIASWARN (strptime); # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define ctime rpl_ctime # endif +# ifndef __cplusplus _GL_ATTRIBUTE_DEPRECATED +# endif _GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp)); @@ -325,6 +437,8 @@ _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp)); # if __GLIBC__ >= 2 _GL_CXXALIASWARN (ctime); # endif +# elif defined GNULIB_POSIXCHECK +/* No need to warn about portability, as a more serious warning is below. */ # endif /* Convert *TP to a date and time string. See @@ -349,6 +463,12 @@ _GL_CXXALIAS_SYS (strftime, size_t, # if __GLIBC__ >= 2 _GL_CXXALIASWARN (strftime); # endif +# elif defined GNULIB_POSIXCHECK +# undef strftime +# if HAVE_RAW_DECL_STRFTIME +_GL_WARN_ON_USE (strftime, "strftime has portability problems - " + "use gnulib module strftime-fixes for portability"); +# endif # endif # if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@ @@ -423,7 +543,15 @@ _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (timegm); +# endif +# elif defined GNULIB_POSIXCHECK +# undef timegm +# if HAVE_RAW_DECL_TIMEGM +_GL_WARN_ON_USE (timegm, "timegm is unportable - " + "use gnulib module timegm for portability"); +# endif # endif /* Encourage applications to avoid unsafe functions that can overrun @@ -431,8 +559,10 @@ _GL_CXXALIASWARN (timegm); applications should use strftime (or even sprintf) instead. */ # if defined GNULIB_POSIXCHECK # undef asctime +# if HAVE_RAW_DECL_ASCTIME _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " "better use strftime (or even sprintf) instead"); +# endif # endif # if defined GNULIB_POSIXCHECK # undef asctime_r @@ -443,8 +573,10 @@ _GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - " # endif # if defined GNULIB_POSIXCHECK # undef ctime +# if HAVE_RAW_DECL_CTIME _GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - " "better use strftime (or even sprintf) instead"); +# endif # endif # if defined GNULIB_POSIXCHECK # undef ctime_r diff --git a/gl/time_r.c b/gl/time_r.c index 97be4fd..b724f3b 100644 --- a/gl/time_r.c +++ b/gl/time_r.c @@ -1,6 +1,6 @@ /* Reentrant time functions like localtime_r. - Copyright (C) 2003, 2006-2007, 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2010-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -21,6 +21,11 @@ #include +/* The replacement functions in this file are only used on native Windows. + They are multithread-safe, because the gmtime() and localtime() functions + on native Windows — both in the ucrt and in the older MSVCRT — return a + pointer to a 'struct tm' in thread-local memory. */ + static struct tm * copy_tm_result (struct tm *dest, struct tm const *src) { diff --git a/gl/timegm.c b/gl/timegm.c index b47025a..e5cf30c 100644 --- a/gl/timegm.c +++ b/gl/timegm.c @@ -1,6 +1,6 @@ /* Convert UTC calendar time to simple time. Like mktime but assumes UTC. - Copyright (C) 1994-2023 Free Software Foundation, Inc. + Copyright (C) 1994-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/gl/unistd.c b/gl/unistd.c index be7a825..f3b3f7b 100644 --- a/gl/unistd.c +++ b/gl/unistd.c @@ -1,6 +1,6 @@ /* Inline functions for . - Copyright (C) 2012-2023 Free Software Foundation, Inc. + Copyright (C) 2012-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,5 +18,5 @@ #include #define _GL_UNISTD_INLINE _GL_EXTERN_INLINE -#include "unistd.h" +#include typedef int dummy; diff --git a/gl/unistd.in.h b/gl/unistd.in.h index 4812fdb..b412966 100644 --- a/gl/unistd.in.h +++ b/gl/unistd.in.h @@ -1,5 +1,5 @@ /* Substitute for and wrapper around . - Copyright (C) 2003-2023 Free Software Foundation, Inc. + Copyright (C) 2003-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -40,6 +40,24 @@ # undef _GL_INCLUDING_UNISTD_H #endif +/* Avoid lseek bugs in FreeBSD, macOS . + This bug is fixed after FreeBSD 13; see . + Use macOS "9999" to stand for a future fixed macOS version. */ +#if defined __FreeBSD__ && __FreeBSD__ < 14 +# undef SEEK_DATA +# undef SEEK_HOLE +#elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA +# ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +# include +# endif +# if (!defined MAC_OS_X_VERSION_MIN_REQUIRED \ + || MAC_OS_X_VERSION_MIN_REQUIRED < 99990000) +# include /* It also defines the two macros. */ +# undef SEEK_DATA +# undef SEEK_HOLE +# endif +#endif + /* Get all possible declarations of gethostname(). */ #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ && !defined _GL_INCLUDING_WINSOCK2_H @@ -51,6 +69,12 @@ #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H #define _@GUARD_PREFIX@_UNISTD_H +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* NetBSD 5.0 mis-defines NULL. Also get size_t. */ /* But avoid namespace pollution on glibc systems. */ #ifndef __GLIBC__ @@ -152,9 +176,6 @@ # include #endif -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_UNISTD_INLINE # define _GL_UNISTD_INLINE _GL_INLINE @@ -541,17 +562,22 @@ _GL_CXXALIASWARN (dup2); Return newfd if successful, otherwise -1 and errno set. See the Linux man page at . */ -# if @HAVE_DUP3@ +# if @REPLACE_DUP3@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef dup3 # define dup3 rpl_dup3 # endif _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags)); _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags)); # else +# if !@HAVE_DUP3@ _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags)); +# endif _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (dup3); +# endif #elif defined GNULIB_POSIXCHECK # undef dup3 # if HAVE_RAW_DECL_DUP3 @@ -870,7 +896,9 @@ _GL_FUNCDECL_SYS (execvpe, int, _GL_CXXALIAS_SYS (execvpe, int, (const char *program, char * const *argv, char * const *env)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (execvpe); +# endif #elif defined GNULIB_POSIXCHECK # undef execvpe # if HAVE_RAW_DECL_EXECVPE @@ -925,7 +953,9 @@ _GL_FUNCDECL_SYS (faccessat, int, _GL_CXXALIAS_SYS (faccessat, int, (int fd, char const *file, int mode, int flag)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (faccessat); +# endif #elif defined GNULIB_POSIXCHECK # undef faccessat # if HAVE_RAW_DECL_FACCESSAT @@ -941,23 +971,28 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - " Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification . */ -# if ! @HAVE_FCHDIR@ +# if @REPLACE_FCHDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fchdir +# define fchdir rpl_fchdir +# endif +_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/)); +_GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/)); +# else +# if !@HAVE_FCHDIR@ || !@HAVE_DECL_FCHDIR@ _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); - +# endif +_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); +# endif +_GL_CXXALIASWARN (fchdir); +# if @REPLACE_FCHDIR@ || !@HAVE_FCHDIR@ /* Gnulib internal hooks needed to maintain the fchdir metadata. */ _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename) _GL_ARG_NONNULL ((2)); _GL_EXTERN_C void _gl_unregister_fd (int fd); _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd); _GL_EXTERN_C const char *_gl_directory_name (int fd); - -# else -# if !@HAVE_DECL_FCHDIR@ -_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); -# endif # endif -_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); -_GL_CXXALIASWARN (fchdir); #elif defined GNULIB_POSIXCHECK # undef fchdir # if HAVE_RAW_DECL_FCHDIR @@ -1002,11 +1037,22 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - " Return 0 if successful, otherwise -1 and errno set. See POSIX:2008 specification . */ -# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ +# if @REPLACE_FDATASYNC@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fdatasync +# define fdatasync rpl_fdatasync +# endif +_GL_FUNCDECL_RPL (fdatasync, int, (int fd)); +_GL_CXXALIAS_RPL (fdatasync, int, (int fd)); +# else +# if !@HAVE_FDATASYNC@|| !@HAVE_DECL_FDATASYNC@ _GL_FUNCDECL_SYS (fdatasync, int, (int fd)); -# endif +# endif _GL_CXXALIAS_SYS (fdatasync, int, (int fd)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fdatasync); +# endif #elif defined GNULIB_POSIXCHECK # undef fdatasync # if HAVE_RAW_DECL_FDATASYNC @@ -1053,7 +1099,9 @@ _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); # endif _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (ftruncate); +# endif #elif defined GNULIB_POSIXCHECK # undef ftruncate # if HAVE_RAW_DECL_FTRUNCATE @@ -1070,10 +1118,10 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " or SIZE was too small. See the POSIX:2008 specification . - Additionally, the gnulib module 'getcwd' guarantees the following GNU - extension: If BUF is NULL, an array is allocated with 'malloc'; the array - is SIZE bytes long, unless SIZE == 0, in which case it is as big as - necessary. */ + Additionally, the gnulib module 'getcwd' or 'getcwd-lgpl' guarantees the + following GNU extension: If BUF is NULL, an array is allocated with + 'malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case + it is as big as necessary. */ # if @REPLACE_GETCWD@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define getcwd rpl_getcwd @@ -1185,11 +1233,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - " #if @GNULIB_GETENTROPY@ /* Fill a buffer with random bytes. */ -# if !@HAVE_GETENTROPY@ +# if @REPLACE_GETENTROPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getentropy +# define getentropy rpl_getentropy +# endif +_GL_FUNCDECL_RPL (getentropy, int, (void *buffer, size_t length)); +_GL_CXXALIAS_RPL (getentropy, int, (void *buffer, size_t length)); +# else +# if !@HAVE_GETENTROPY@ _GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length)); -# endif +# endif _GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getentropy); +# endif #elif defined GNULIB_POSIXCHECK # undef getentropy # if HAVE_RAW_DECL_GETENTROPY @@ -1323,7 +1382,9 @@ _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size) int size. */ _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getlogin_r); +# endif #elif defined GNULIB_POSIXCHECK # undef getlogin_r # if HAVE_RAW_DECL_GETLOGIN_R @@ -1661,7 +1722,9 @@ _GL_CXXALIAS_SYS (linkat, int, (int fd1, const char *path1, int fd2, const char *path2, int flag)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (linkat); +# endif #elif defined GNULIB_POSIXCHECK # undef linkat # if HAVE_RAW_DECL_LINKAT @@ -1742,8 +1805,9 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - " Return 0 upon success, or -1 with errno set upon failure. See also the Linux man page at . */ -# if @HAVE_PIPE2@ +# if @REPLACE_PIPE2@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pipe2 # define pipe2 rpl_pipe2 # endif _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); @@ -1752,7 +1816,9 @@ _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags)); _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (pipe2); +# endif #elif defined GNULIB_POSIXCHECK # undef pipe2 # if HAVE_RAW_DECL_PIPE2 @@ -1787,7 +1853,9 @@ _GL_FUNCDECL_SYS (pread, ssize_t, _GL_CXXALIAS_SYS (pread, ssize_t, (int fd, void *buf, size_t bufsize, off_t offset)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (pread); +# endif #elif defined GNULIB_POSIXCHECK # undef pread # if HAVE_RAW_DECL_PREAD @@ -1822,7 +1890,9 @@ _GL_FUNCDECL_SYS (pwrite, ssize_t, _GL_CXXALIAS_SYS (pwrite, ssize_t, (int fd, const void *buf, size_t bufsize, off_t offset)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (pwrite); +# endif #elif defined GNULIB_POSIXCHECK # undef pwrite # if HAVE_RAW_DECL_PWRITE @@ -1936,7 +2006,9 @@ _GL_CXXALIAS_SYS (readlinkat, ssize_t, (int fd, char const *restrict file, char *restrict buf, size_t len)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (readlinkat); +# endif #elif defined GNULIB_POSIXCHECK # undef readlinkat # if HAVE_RAW_DECL_READLINKAT @@ -1996,15 +2068,27 @@ _GL_CXXALIASWARN (rmdir); Platforms with no ability to set the hostname return -1 and set errno = ENOSYS. */ -# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ +# if @REPLACE_SETHOSTNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sethostname +# define sethostname rpl_sethostname +# endif +_GL_FUNCDECL_RPL (sethostname, int, (const char *name, size_t len) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (sethostname, int, (const char *name, size_t len)); +# else +# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) _GL_ARG_NONNULL ((1))); -# endif +# endif /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5 and FreeBSD 6.4 the second parameter is int. On Solaris 11 2011-10, the first parameter is not const. */ _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (sethostname); +# endif #elif defined GNULIB_POSIXCHECK # undef sethostname # if HAVE_RAW_DECL_SETHOSTNAME @@ -2113,7 +2197,9 @@ _GL_FUNCDECL_SYS (symlinkat, int, _GL_CXXALIAS_SYS (symlinkat, int, (char const *contents, int fd, char const *file)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (symlinkat); +# endif #elif defined GNULIB_POSIXCHECK # undef symlinkat # if HAVE_RAW_DECL_SYMLINKAT @@ -2143,7 +2229,9 @@ _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length) # endif _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (truncate); +# endif #elif defined GNULIB_POSIXCHECK # undef truncate # if HAVE_RAW_DECL_TRUNCATE @@ -2173,7 +2261,9 @@ _GL_FUNCDECL_SYS (ttyname_r, int, _GL_CXXALIAS_SYS (ttyname_r, int, (int fd, char *buf, size_t buflen)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (ttyname_r); +# endif #elif defined GNULIB_POSIXCHECK # undef ttyname_r # if HAVE_RAW_DECL_TTYNAME_R diff --git a/gl/unlocked-io.h b/gl/unlocked-io.h index fdef624..0cd9bbf 100644 --- a/gl/unlocked-io.h +++ b/gl/unlocked-io.h @@ -1,6 +1,6 @@ /* Prefer faster, non-thread-safe stdio functions if available. - Copyright (C) 2001-2004, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2009-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,11 @@ the *_unlocked functions directly. On hosts that lack those functions, invoke the non-thread-safe versions instead. */ +/* This file uses HAVE_DECL_*_UNLOCKED. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + # include # if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked @@ -96,7 +101,7 @@ # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) # endif -# if HAVE_DECL_GETC_UNLOCKED || defined get_unlocked +# if HAVE_DECL_GETC_UNLOCKED || defined getc_unlocked # undef getc # define getc(x) getc_unlocked (x) # else diff --git a/gl/unsetenv.c b/gl/unsetenv.c index e548949..d8ada2a 100644 --- a/gl/unsetenv.c +++ b/gl/unsetenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1995-2002, 2005-2023 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995-2002, 2005-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. This file is free software: you can redistribute it and/or modify diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c index 277c39e..de20445 100644 --- a/gl/vasnprintf.c +++ b/gl/vasnprintf.c @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2023 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -83,9 +83,9 @@ #include /* snprintf(), sprintf() */ #include /* abort(), malloc(), realloc(), free() */ #include /* memcpy(), strlen() */ -#include /* mbstate_t, mbrtowc(), mbrlen(), wcrtomb() */ +#include /* mbstate_t, mbrtowc(), mbrlen(), wcrtomb(), mbszero() */ #include /* errno */ -#include /* CHAR_BIT */ +#include /* CHAR_BIT, INT_WIDTH, LONG_WIDTH */ #include /* DBL_MAX_EXP, LDBL_MAX_EXP */ #if HAVE_NL_LANGINFO # include @@ -103,29 +103,29 @@ #include "attribute.h" -#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL +#if NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) # include # include "float+.h" #endif -#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL +#if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE # include # include "isnand-nolibm.h" #endif -#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL +#if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) # include # include "isnanl-nolibm.h" # include "fpucw.h" #endif -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL +#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE # include # include "isnand-nolibm.h" # include "printf-frexp.h" #endif -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL +#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) # include # include "isnanl-nolibm.h" # include "printf-frexpl.h" @@ -138,8 +138,6 @@ # define VASNPRINTF vasnwprintf # define FCHAR_T wchar_t # define DCHAR_T wchar_t -# define TCHAR_T wchar_t -# define DCHAR_IS_TCHAR 1 # define DIRECTIVE wchar_t_directive # define DIRECTIVES wchar_t_directives # define PRINTF_PARSE wprintf_parse @@ -159,24 +157,32 @@ # endif #endif #if WIDE_CHAR_VERSION - /* TCHAR_T is wchar_t. */ -# define USE_SNPRINTF 1 -# if HAVE_DECL__SNWPRINTF - /* On Windows, the function swprintf() has a different signature than - on Unix; we use the function _snwprintf() or - on mingw - snwprintf() - instead. The mingw function snwprintf() has fewer bugs than the - MSVCRT function _snwprintf(), so prefer that. */ -# if defined __MINGW32__ -# define SNPRINTF snwprintf + /* DCHAR_T is wchar_t. */ +# if HAVE_DECL__SNWPRINTF || (HAVE_SWPRINTF && HAVE_WORKING_SWPRINTF) +# define TCHAR_T wchar_t +# define DCHAR_IS_TCHAR 1 +# define USE_SNPRINTF 1 +# if HAVE_DECL__SNWPRINTF + /* On Windows, the function swprintf() has a different signature than + on Unix; we use the function _snwprintf() or - on mingw - snwprintf() + instead. The mingw function snwprintf() has fewer bugs than the + MSVCRT function _snwprintf(), so prefer that. */ +# if defined __MINGW32__ +# define SNPRINTF snwprintf +# else +# define SNPRINTF _snwprintf +# define USE_MSVC__SNPRINTF 1 +# endif # else -# define SNPRINTF _snwprintf -# define USE_MSVC__SNPRINTF 1 + /* Unix. */ +# define SNPRINTF swprintf # endif # else - /* Unix. */ -# define SNPRINTF swprintf + /* Old platforms such as NetBSD 3.0, OpenBSD 3.8, HP-UX 11.00, IRIX 6.5. */ +# define TCHAR_T char # endif -#else +#endif +#if !WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR /* TCHAR_T is char. */ /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'. But don't use it on BeOS, since BeOS snprintf produces no output if the @@ -241,7 +247,7 @@ local_strnlen (const char *string, size_t maxlen) # endif #endif -#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T +#if (((!USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_WPRINTF_DIRECTIVE_LC) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T # if HAVE_WCSLEN # define local_wcslen wcslen # else @@ -264,8 +270,8 @@ local_wcslen (const wchar_t *s) # endif #endif -#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && HAVE_WCHAR_T && WIDE_CHAR_VERSION -# if HAVE_WCSNLEN +#if (!USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && HAVE_WCHAR_T && WIDE_CHAR_VERSION +# if HAVE_WCSNLEN && HAVE_DECL_WCSNLEN # define local_wcsnlen wcsnlen # else # ifndef local_wcsnlen_defined @@ -283,12 +289,12 @@ local_wcsnlen (const wchar_t *s, size_t maxlen) # endif #endif -#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) || (ENABLE_WCHAR_FALLBACK && HAVE_WINT_T)) && !WIDE_CHAR_VERSION +#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) || ((NEED_PRINTF_DIRECTIVE_LC || ENABLE_WCHAR_FALLBACK) && HAVE_WINT_T)) && !WIDE_CHAR_VERSION # if ENABLE_WCHAR_FALLBACK static size_t wctomb_fallback (char *s, wchar_t wc) { - static char hex[16] = "0123456789ABCDEF"; + static char const hex[16] = "0123456789ABCDEF"; s[0] = '\\'; if (sizeof (wchar_t) > 2 && wc > 0xffff) @@ -351,7 +357,7 @@ local_wctomb (char *s, wchar_t wc) # endif #endif -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL +#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) /* Determine the decimal-point character according to the current locale. */ # ifndef decimal_point_char_defined # define decimal_point_char_defined 1 @@ -378,7 +384,7 @@ decimal_point_char (void) # endif #endif -#if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE && !defined IN_LIBINTL +#if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE /* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ static int @@ -389,7 +395,7 @@ is_infinite_or_zero (double x) #endif -#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL +#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE /* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ static int @@ -400,7 +406,7 @@ is_infinite_or_zerol (long double x) #endif -#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL +#if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE /* Converting 'long double' to decimal without rare rounding bugs requires real bignums. We use the naming conventions of GNU gmp, but vastly simpler @@ -921,6 +927,14 @@ divide (mpn_t a, mpn_t b, mpn_t *q) return roomptr; } +/* Avoid pointless GCC warning "argument 1 value '18446744073709551615' exceeds + maximum object size 9223372036854775807", triggered by the use of xsum as + argument of malloc. */ +# if __GNUC__ >= 7 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Walloc-size-larger-than=" +# endif + /* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal representation. Destroys the contents of a. @@ -977,6 +991,10 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes) return c_ptr; } +# if __GNUC__ >= 7 +# pragma GCC diagnostic pop +# endif + # if NEED_PRINTF_LONG_DOUBLE /* Assuming x is finite and >= 0: @@ -1171,8 +1189,6 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) void *z_memory; char *digits; - if (memory == NULL) - return NULL; /* x = 2^e * m, hence y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m) = round (2^s * 5^n * m). */ @@ -1380,10 +1396,13 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) static char * scale10_round_decimal_long_double (long double x, int n) { - int e IF_LINT(= 0); + int e; mpn_t m; void *memory = decode_long_double (x, &e, &m); - return scale10_round_decimal_decoded (e, m, memory, n); + if (memory != NULL) + return scale10_round_decimal_decoded (e, m, memory, n); + else + return NULL; } # endif @@ -1398,10 +1417,13 @@ scale10_round_decimal_long_double (long double x, int n) static char * scale10_round_decimal_double (double x, int n) { - int e IF_LINT(= 0); + int e; mpn_t m; void *memory = decode_double (x, &e, &m); - return scale10_round_decimal_decoded (e, m, memory, n); + if (memory != NULL) + return scale10_round_decimal_decoded (e, m, memory, n); + else + return NULL; } # endif @@ -1604,7 +1626,7 @@ is_borderline (const char *digits, size_t precision) #endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF +#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF /* Use a different function name, to make it possible that the 'wchar_t' parametrization and the 'char' parametrization get compiled in the same @@ -1627,24 +1649,156 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, switch (conversion) { case 'd': case 'i': case 'u': - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_LONGINT: + tmp_length = + (unsigned int) (sizeof (long int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_LONGLONGINT: + tmp_length = + (unsigned int) (sizeof (long long int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT8_T: + tmp_length = + (unsigned int) (sizeof (int8_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT16_T: + tmp_length = + (unsigned int) (sizeof (int16_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT32_T: + tmp_length = + (unsigned int) (sizeof (int32_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT64_T: + tmp_length = + (unsigned int) (sizeof (int64_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (int_fast8_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (int_fast16_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (int_fast32_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (int_fast64_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + } if (tmp_length < precision) tmp_length = precision; /* Multiply by 2, as an estimate for FLAG_GROUP. */ @@ -1653,25 +1807,156 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, tmp_length = xsum (tmp_length, 1); break; + case 'b': + #if SUPPORT_GNU_PRINTF_DIRECTIVES \ + || (__GLIBC__ + (__GLIBC_MINOR__ >= 35) > 2) + case 'B': + #endif + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + } + if (tmp_length < precision) + tmp_length = precision; + /* Add 2, to account for a prefix from the alternate form. */ + tmp_length = xsum (tmp_length, 2); + break; + case 'o': - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + } if (tmp_length < precision) tmp_length = precision; /* Add 1, to account for a leading sign. */ @@ -1679,27 +1964,89 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, break; case 'x': case 'X': - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + } if (tmp_length < precision) tmp_length = precision; - /* Add 2, to account for a leading sign or alternate form. */ + /* Add 2, to account for a prefix from the alternate form. */ tmp_length = xsum (tmp_length, 2); break; @@ -1988,6 +2335,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (dp->conversion == 'n') { +#if NEED_PRINTF_WITH_N_DIRECTIVE switch (a.arg[dp->arg_index].type) { case TYPE_COUNT_SCHAR_POINTER: @@ -2005,9 +2353,36 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, case TYPE_COUNT_LONGLONGINT_POINTER: *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; break; + case TYPE_COUNT_INT8_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int8_t_pointer = length; + break; + case TYPE_COUNT_INT16_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int16_t_pointer = length; + break; + case TYPE_COUNT_INT32_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int32_t_pointer = length; + break; + case TYPE_COUNT_INT64_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int64_t_pointer = length; + break; + case TYPE_COUNT_INT_FAST8_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int_fast8_t_pointer = length; + break; + case TYPE_COUNT_INT_FAST16_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int_fast16_t_pointer = length; + break; + case TYPE_COUNT_INT_FAST32_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int_fast32_t_pointer = length; + break; + case TYPE_COUNT_INT_FAST64_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int_fast64_t_pointer = length; + break; default: abort (); } +#else + abort (); +#endif } #if ENABLE_UNISTDIO /* The unistdio extensions. */ @@ -2130,7 +2505,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (characters < width && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2175,7 +2550,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } # endif - if (characters < width && (dp->flags & FLAG_LEFT)) + if (characters < width && (flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2232,7 +2607,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (characters < width && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2277,7 +2652,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } # endif - if (characters < width && (dp->flags & FLAG_LEFT)) + if (characters < width && (flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2334,7 +2709,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (characters < width && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2379,7 +2754,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } # endif - if (characters < width && (dp->flags & FLAG_LEFT)) + if (characters < width && (flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2394,7 +2769,150 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } #endif -#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T +#if WIDE_CHAR_VERSION && (!DCHAR_IS_TCHAR || NEED_WPRINTF_DIRECTIVE_LC) + else if ((dp->conversion == 's' + && a.arg[dp->arg_index].type == TYPE_WIDE_STRING) + || (dp->conversion == 'c' + && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR)) + { + /* %ls or %lc in vasnwprintf. See the specification of + fwprintf. */ + /* It would be silly to use snprintf ("%ls", ...) and then + convert back the result from a char[] to a wchar_t[]. + Instead, just copy the argument wchar_t[] to the result. */ + int flags = dp->flags; + size_t width; + + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + } + + { + const wchar_t *ls_arg; + wchar_t lc_arg[1]; + size_t characters; + + if (dp->conversion == 's') + { + int has_precision; + size_t precision; + + has_precision = 0; + precision = 6; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; + + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } + + ls_arg = a.arg[dp->arg_index].a.a_wide_string; + + if (has_precision) + { + /* Use only at most PRECISION wide characters, from + the left. */ + const wchar_t *ls_arg_end; + + ls_arg_end = ls_arg; + characters = 0; + for (; precision > 0; precision--) + { + if (*ls_arg_end == 0) + /* Found the terminating null wide character. */ + break; + ls_arg_end++; + characters++; + } + } + else + { + /* Use the entire string, and count the number of wide + characters. */ + characters = local_wcslen (ls_arg); + } + } + else /* dp->conversion == 'c' */ + { + lc_arg[0] = (wchar_t) a.arg[dp->arg_index].a.a_wide_char; + ls_arg = lc_arg; + characters = 1; + } + + { + size_t total = (characters < width ? width : characters); + ENSURE_ALLOCATION (xsum (length, total)); + + if (characters < width && !(flags & FLAG_LEFT)) + { + size_t n = width - characters; + DCHAR_SET (result + length, ' ', n); + length += n; + } + + if (characters > 0) + { + DCHAR_CPY (result + length, ls_arg, characters); + length += characters; + } + + if (characters < width && (flags & FLAG_LEFT)) + { + size_t n = width - characters; + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + } + } +#endif +#if (!USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T else if (dp->conversion == 's' # if WIDE_CHAR_VERSION && a.arg[dp->arg_index].type != TYPE_WIDE_STRING @@ -2493,7 +3011,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, wide characters, from the left. */ # if HAVE_MBRTOWC mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif arg_end = arg; characters = 0; @@ -2521,7 +3039,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters. */ # if HAVE_MBRTOWC mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif arg_end = arg; characters = 0; @@ -2551,7 +3069,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (characters < width && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2565,7 +3083,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, size_t remaining; # if HAVE_MBRTOWC mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif ENSURE_ALLOCATION (xsum (length, characters)); for (remaining = characters; remaining > 0; remaining--) @@ -2591,7 +3109,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { # if HAVE_MBRTOWC mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif while (arg < arg_end) { @@ -2602,17 +3120,19 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, # else count = mbtowc (&wc, arg, arg_end - arg); # endif - if (count <= 0) - /* mbrtowc not consistent with mbrlen, or mbtowc - not consistent with mblen. */ + if (count == 0) + /* mbrtowc not consistent with strlen. */ abort (); + if (count < 0) + /* Invalid or incomplete multibyte character. */ + goto fail_with_EILSEQ; ENSURE_ALLOCATION (xsum (length, 1)); result[length++] = wc; arg += count; } } - if (characters < width && (dp->flags & FLAG_LEFT)) + if (characters < width && (flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2641,7 +3161,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, at most PRECISION bytes, from the left. */ # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif arg_end = arg; characters = 0; @@ -2674,7 +3194,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, bytes. */ # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif arg_end = arg; characters = 0; @@ -2714,7 +3234,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, size_t remaining; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif for (remaining = characters; remaining > 0; ) { @@ -2768,7 +3288,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* w doesn't matter. */ w = 0; - if (w < width && !(dp->flags & FLAG_LEFT)) + if (w < width && !(flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); @@ -2783,7 +3303,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, size_t remaining; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif ENSURE_ALLOCATION (xsum (length, characters)); for (remaining = characters; remaining > 0; ) @@ -2809,7 +3329,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif while (arg < arg_end) { @@ -2836,7 +3356,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += tmpdst_len; # endif - if (w < width && (dp->flags & FLAG_LEFT)) + if (w < width && (flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); @@ -2847,12 +3367,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, # endif } #endif -#if ENABLE_WCHAR_FALLBACK && HAVE_WINT_T && !WIDE_CHAR_VERSION +#if (NEED_PRINTF_DIRECTIVE_LC || ENABLE_WCHAR_FALLBACK) && HAVE_WINT_T && !WIDE_CHAR_VERSION else if (dp->conversion == 'c' && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR) { /* Implement the 'lc' directive ourselves, in order to provide - the fallback that avoids EILSEQ. */ + a correct behaviour for the null wint_t argument and/or the + fallback that avoids EILSEQ. */ int flags = dp->flags; int has_width; size_t width; @@ -2907,21 +3428,18 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { /* Count the number of bytes. */ characters = 0; - if (arg != 0) - { - char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbstate_t state; + mbszero (&state); # endif - count = local_wcrtomb (cbuf, arg, &state); - if (count < 0) - /* Inconsistency. */ - abort (); - characters = count; - } + count = local_wcrtomb (cbuf, arg, &state); + if (count < 0) + /* Cannot convert. */ + goto fail_with_EILSEQ; + characters = count; } # if DCHAR_IS_TCHAR else @@ -2933,13 +3451,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, # if !DCHAR_IS_TCHAR /* Convert the string into a piece of temporary memory. */ - if (characters > 0) /* implies arg != 0 */ + if (characters > 0) { char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ int count; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif count = local_wcrtomb (cbuf, arg, &state); @@ -2977,7 +3495,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* w doesn't matter. */ w = 0; - if (w < width && !(dp->flags & FLAG_LEFT)) + if (w < width && !(flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); @@ -2990,12 +3508,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { /* We know the number of bytes in advance. */ ENSURE_ALLOCATION (xsum (length, characters)); - if (characters > 0) /* implies arg != 0 */ + if (characters > 0) { int count; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); # endif count = local_wcrtomb (result + length, arg, &state); @@ -3007,23 +3525,20 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } else { - if (arg != 0) - { - char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbstate_t state; + mbszero (&state); # endif - count = local_wcrtomb (cbuf, arg, &state); - if (count <= 0) - /* Inconsistency. */ - abort (); - ENSURE_ALLOCATION (xsum (length, count)); - memcpy (result + length, cbuf, count); - length += count; - } + count = local_wcrtomb (cbuf, arg, &state); + if (count < 0) + /* Cannot convert. */ + goto fail_with_EILSEQ; + ENSURE_ALLOCATION (xsum (length, count)); + memcpy (result + length, cbuf, count); + length += count; } # else ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len), @@ -3033,7 +3548,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += tmpdst_len; # endif - if (w < width && (dp->flags & FLAG_LEFT)) + if (w < width && (flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); @@ -3043,15 +3558,400 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } #endif -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL - else if ((dp->conversion == 'a' || dp->conversion == 'A') -# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) - && (0 -# if NEED_PRINTF_DOUBLE - || a.arg[dp->arg_index].type == TYPE_DOUBLE -# endif -# if NEED_PRINTF_LONG_DOUBLE - || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE +#if NEED_WPRINTF_DIRECTIVE_C && WIDE_CHAR_VERSION + else if (dp->conversion == 'c' + && a.arg[dp->arg_index].type != TYPE_WIDE_CHAR) + { + /* Implement the 'c' directive ourselves, in order to avoid + EILSEQ in the "C" locale. */ + int flags = dp->flags; + size_t width; + + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + } + + /* %c in vasnwprintf. See the specification of fwprintf. */ + { + char arg = (char) a.arg[dp->arg_index].a.a_char; + mbstate_t state; + wchar_t wc; + + mbszero (&state); + int count = mbrtowc (&wc, &arg, 1, &state); + if (count < 0) + /* Invalid or incomplete multibyte character. */ + goto fail_with_EILSEQ; + + if (1 < width && !(flags & FLAG_LEFT)) + { + size_t n = width - 1; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + + ENSURE_ALLOCATION (xsum (length, 1)); + result[length++] = wc; + + if (1 < width && (flags & FLAG_LEFT)) + { + size_t n = width - 1; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + } +#endif +#if NEED_PRINTF_DIRECTIVE_B || NEED_PRINTF_DIRECTIVE_UPPERCASE_B + else if (0 +# if NEED_PRINTF_DIRECTIVE_B + || (dp->conversion == 'b') +# endif +# if NEED_PRINTF_DIRECTIVE_UPPERCASE_B + || (dp->conversion == 'B') +# endif + ) + { + arg_type type = a.arg[dp->arg_index].type; + int flags = dp->flags; + int has_width; + size_t width; + int has_precision; + size_t precision; + size_t tmp_length; + size_t count; + DCHAR_T tmpbuf[700]; + DCHAR_T *tmp; + DCHAR_T *tmp_end; + DCHAR_T *tmp_start; + DCHAR_T *pad_ptr; + DCHAR_T *p; + + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } + + has_precision = 0; + precision = 1; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; + + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } + + /* Allocate a temporary buffer of sufficient size. */ + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + } + if (tmp_length < precision) + tmp_length = precision; + /* Add 2, to account for a prefix from the alternate form. */ + tmp_length = xsum (tmp_length, 2); + + if (tmp_length < width) + tmp_length = width; + + if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) + tmp = tmpbuf; + else + { + size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); + + if (size_overflow_p (tmp_memsize)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + tmp = (DCHAR_T *) malloc (tmp_memsize); + if (tmp == NULL) + /* Out of memory. */ + goto out_of_memory; + } + + tmp_end = tmp + tmp_length; + + unsigned long long arg; + switch (type) + { + case TYPE_UCHAR: + arg = a.arg[dp->arg_index].a.a_uchar; + break; + case TYPE_USHORT: + arg = a.arg[dp->arg_index].a.a_ushort; + break; + case TYPE_UINT: + arg = a.arg[dp->arg_index].a.a_uint; + break; + case TYPE_ULONGINT: + arg = a.arg[dp->arg_index].a.a_ulongint; + break; + case TYPE_ULONGLONGINT: + arg = a.arg[dp->arg_index].a.a_ulonglongint; + break; + case TYPE_UINT8_T: + arg = a.arg[dp->arg_index].a.a_uint8_t; + break; + case TYPE_UINT16_T: + arg = a.arg[dp->arg_index].a.a_uint16_t; + break; + case TYPE_UINT32_T: + arg = a.arg[dp->arg_index].a.a_uint32_t; + break; + case TYPE_UINT64_T: + arg = a.arg[dp->arg_index].a.a_uint64_t; + break; + case TYPE_UINT_FAST8_T: + arg = a.arg[dp->arg_index].a.a_uint_fast8_t; + break; + case TYPE_UINT_FAST16_T: + arg = a.arg[dp->arg_index].a.a_uint_fast16_t; + break; + case TYPE_UINT_FAST32_T: + arg = a.arg[dp->arg_index].a.a_uint_fast32_t; + break; + case TYPE_UINT_FAST64_T: + arg = a.arg[dp->arg_index].a.a_uint_fast64_t; + break; + default: + abort (); + } + int need_prefix = ((flags & FLAG_ALT) && arg != 0); + + p = tmp_end; + /* "The result of converting a zero value with a precision + of zero is no characters." */ + if (!(has_precision && precision == 0 && arg == 0)) + { + do + { + *--p = '0' + (arg & 1); + arg = arg >> 1; + } + while (arg != 0); + } + + if (has_precision) + { + DCHAR_T *digits_start = tmp_end - precision; + while (p > digits_start) + *--p = '0'; + } + + pad_ptr = p; + + if (need_prefix) + { +# if NEED_PRINTF_DIRECTIVE_B && !NEED_PRINTF_DIRECTIVE_UPPERCASE_B + *--p = 'b'; +# elif NEED_PRINTF_DIRECTIVE_UPPERCASE_B && !NEED_PRINTF_DIRECTIVE_B + *--p = 'B'; +# else + *--p = dp->conversion; +# endif + *--p = '0'; + } + tmp_start = p; + + /* The generated string now extends from tmp_start to tmp_end, + with the zero padding insertion point being at pad_ptr, + tmp_start <= pad_ptr <= tmp_end. */ + count = tmp_end - tmp_start; + + if (count < width) + { + size_t pad = width - count; + + if (flags & FLAG_LEFT) + { + /* Pad with spaces on the right. */ + for (p = tmp_start; p < tmp_end; p++) + *(p - pad) = *p; + for (p = tmp_end - pad; p < tmp_end; p++) + *p = ' '; + } + else if ((flags & FLAG_ZERO) + /* Neither ISO C nor POSIX specify that the '0' + flag is ignored when a width and a precision + are both present. But most implementations + do so. */ + && !(has_width && has_precision)) + { + /* Pad with zeroes. */ + for (p = tmp_start; p < pad_ptr; p++) + *(p - pad) = *p; + for (p = pad_ptr - pad; p < pad_ptr; p++) + *p = '0'; + } + else + { + /* Pad with spaces on the left. */ + for (p = tmp_start - pad; p < tmp_start; p++) + *p = ' '; + } + + tmp_start = tmp_start - pad; + } + + count = tmp_end - tmp_start; + + if (count > tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); + + /* Make room for the result. */ + if (count >= allocated - length) + { + size_t n = xsum (length, count); + + ENSURE_ALLOCATION (n); + } + + /* Append the result. */ + memcpy (result + length, tmp_start, count * sizeof (DCHAR_T)); + if (tmp != tmpbuf) + free (tmp); + length += count; + } +#endif +#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) + else if ((dp->conversion == 'a' || dp->conversion == 'A') +# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) + && (0 +# if NEED_PRINTF_DOUBLE + || a.arg[dp->arg_index].type == TYPE_DOUBLE +# endif +# if NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) + || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE # endif ) # endif @@ -3170,7 +4070,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, p = tmp; if (type == TYPE_LONGDOUBLE) { -# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE +# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) long double arg = a.arg[dp->arg_index].a.a_longdouble; if (isnanl (arg)) @@ -3290,7 +4190,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } *p++ = dp->conversion - 'A' + 'P'; -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR { static const wchar_t decimal_format[] = { '%', '+', 'd', '\0' }; @@ -3441,7 +4341,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } *p++ = dp->conversion - 'A' + 'P'; -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR { static const wchar_t decimal_format[] = { '%', '+', 'd', '\0' }; @@ -3533,7 +4433,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += count; } #endif -#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL +#if NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE else if ((dp->conversion == 'f' || dp->conversion == 'F' || dp->conversion == 'e' || dp->conversion == 'E' || dp->conversion == 'g' || dp->conversion == 'G' @@ -3901,7 +4801,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } *p++ = dp->conversion; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR { static const wchar_t decimal_format[] = { '%', '+', '.', '2', 'd', '\0' }; @@ -4082,7 +4982,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR { static const wchar_t decimal_format[] = { '%', '+', '.', '2', 'd', '\0' }; @@ -4359,7 +5259,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } *p++ = dp->conversion; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR { static const wchar_t decimal_format[] = /* Produce the same number of exponent digits @@ -4552,7 +5452,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR { static const wchar_t decimal_format[] = /* Produce the same number of exponent digits @@ -4720,24 +5620,24 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { arg_type type = a.arg[dp->arg_index].type; int flags = dp->flags; -#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION int has_width; #endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION size_t width; #endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION int has_precision; size_t precision; #endif -#if NEED_PRINTF_UNBOUNDED_PRECISION +#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION int prec_ourselves; #else # define prec_ourselves 0 #endif -#if NEED_PRINTF_FLAG_LEFTADJUST +#if (WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST # define pad_ourselves 1 -#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION int pad_ourselves; #else # define pad_ourselves 0 @@ -4752,10 +5652,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, TCHAR_T *tmp; #endif -#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION has_width = 0; #endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION width = 0; if (dp->width_start != dp->width_end) { @@ -4783,13 +5683,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, width = xsum (xtimes (width, 10), *digitp++ - '0'); while (digitp != dp->width_end); } -#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +# if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION has_width = 1; -#endif +# endif } #endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION has_precision = 0; precision = 6; if (dp->precision_start != dp->precision_end) @@ -4822,14 +5722,32 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #endif /* Decide whether to handle the precision ourselves. */ -#if NEED_PRINTF_UNBOUNDED_PRECISION +#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION switch (dp->conversion) { +# if NEED_PRINTF_UNBOUNDED_PRECISION case 'd': case 'i': case 'u': + case 'b': + #if SUPPORT_GNU_PRINTF_DIRECTIVES \ + || (__GLIBC__ + (__GLIBC_MINOR__ >= 35) > 2) + case 'B': + #endif case 'o': - case 'x': case 'X': case 'p': prec_ourselves = has_precision && (precision > 0); break; +# endif + case 'x': case 'X': case 'p': + prec_ourselves = + has_precision + && (0 +# if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO + || (precision == 0) +# endif +# if NEED_PRINTF_UNBOUNDED_PRECISION + || (precision > 0) +# endif + ); + break; default: prec_ourselves = 0; break; @@ -4837,7 +5755,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #endif /* Decide whether to perform the padding ourselves. */ -#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION) +#if !((WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST) && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION) switch (dp->conversion) { # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO @@ -4956,6 +5874,54 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { case TYPE_LONGLONGINT: case TYPE_ULONGLONGINT: + #if INT8_WIDTH > LONG_WIDTH + case TYPE_INT8_T: + #endif + #if UINT8_WIDTH > LONG_WIDTH + case TYPE_UINT8_T: + #endif + #if INT16_WIDTH > LONG_WIDTH + case TYPE_INT16_T: + #endif + #if UINT16_WIDTH > LONG_WIDTH + case TYPE_UINT16_T: + #endif + #if INT32_WIDTH > LONG_WIDTH + case TYPE_INT32_T: + #endif + #if UINT32_WIDTH > LONG_WIDTH + case TYPE_UINT32_T: + #endif + #if INT64_WIDTH > LONG_WIDTH + case TYPE_INT64_T: + #endif + #if UINT64_WIDTH > LONG_WIDTH + case TYPE_UINT64_T: + #endif + #if INT_FAST8_WIDTH > LONG_WIDTH + case TYPE_INT_FAST8_T: + #endif + #if UINT_FAST8_WIDTH > LONG_WIDTH + case TYPE_UINT_FAST8_T: + #endif + #if INT_FAST16_WIDTH > LONG_WIDTH + case TYPE_INT_FAST16_T: + #endif + #if UINT_FAST16_WIDTH > LONG_WIDTH + case TYPE_UINT_FAST16_T: + #endif + #if INT_FAST32_WIDTH > LONG_WIDTH + case TYPE_INT3_FAST2_T: + #endif + #if UINT_FAST32_WIDTH > LONG_WIDTH + case TYPE_UINT_FAST32_T: + #endif + #if INT_FAST64_WIDTH > LONG_WIDTH + case TYPE_INT_FAST64_T: + #endif + #if UINT_FAST64_WIDTH > LONG_WIDTH + case TYPE_UINT_FAST64_T: + #endif #if defined _WIN32 && ! defined __CYGWIN__ *fbp++ = 'I'; *fbp++ = '6'; @@ -4967,12 +5933,60 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, FALLTHROUGH; case TYPE_LONGINT: case TYPE_ULONGINT: -#if HAVE_WINT_T + #if INT8_WIDTH > INT_WIDTH && INT8_WIDTH <= LONG_WIDTH + case TYPE_INT8_T: + #endif + #if UINT8_WIDTH > INT_WIDTH && UINT8_WIDTH <= LONG_WIDTH + case TYPE_UINT8_T: + #endif + #if INT16_WIDTH > INT_WIDTH && INT16_WIDTH <= LONG_WIDTH + case TYPE_INT16_T: + #endif + #if UINT16_WIDTH > INT_WIDTH && UINT16_WIDTH <= LONG_WIDTH + case TYPE_UINT16_T: + #endif + #if INT32_WIDTH > INT_WIDTH && INT32_WIDTH <= LONG_WIDTH + case TYPE_INT32_T: + #endif + #if UINT32_WIDTH > INT_WIDTH && UINT32_WIDTH <= LONG_WIDTH + case TYPE_UINT32_T: + #endif + #if INT64_WIDTH > INT_WIDTH && INT64_WIDTH <= LONG_WIDTH + case TYPE_INT64_T: + #endif + #if UINT64_WIDTH > INT_WIDTH && UINT64_WIDTH <= LONG_WIDTH + case TYPE_UINT64_T: + #endif + #if INT_FAST8_WIDTH > INT_WIDTH && INT_FAST8_WIDTH <= LONG_WIDTH + case TYPE_INT_FAST8_T: + #endif + #if UINT_FAST8_WIDTH > INT_WIDTH && UINT_FAST8_WIDTH <= LONG_WIDTH + case TYPE_UINT_FAST8_T: + #endif + #if INT_FAST16_WIDTH > INT_WIDTH && INT_FAST16_WIDTH <= LONG_WIDTH + case TYPE_INT_FAST16_T: + #endif + #if UINT_FAST16_WIDTH > INT_WIDTH && UINT_FAST16_WIDTH <= LONG_WIDTH + case TYPE_UINT_FAST16_T: + #endif + #if INT_FAST32_WIDTH > INT_WIDTH && INT_FAST32_WIDTH <= LONG_WIDTH + case TYPE_INT_FAST32_T: + #endif + #if UINT_FAST32_WIDTH > INT_WIDTH && UINT_FAST32_WIDTH <= LONG_WIDTH + case TYPE_UINT_FAST32_T: + #endif + #if INT_FAST64_WIDTH > INT_WIDTH && INT_FAST64_WIDTH <= LONG_WIDTH + case TYPE_INT_FAST64_T: + #endif + #if UINT_FAST64_WIDTH > INT_WIDTH && UINT_FAST64_WIDTH <= LONG_WIDTH + case TYPE_UINT_FAST64_T: + #endif + #if HAVE_WINT_T case TYPE_WIDE_CHAR: -#endif -#if HAVE_WCHAR_T + #endif + #if HAVE_WCHAR_T case TYPE_WIDE_STRING: -#endif + #endif *fbp++ = 'l'; break; case TYPE_LONGDOUBLE: @@ -4988,47 +6002,74 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #endif *fbp = dp->conversion; #if USE_SNPRINTF -# if ((HAVE_SNPRINTF_RETVAL_C99 && HAVE_SNPRINTF_TRUNCATION_C99) \ + /* Decide whether to pass %n in the format string + to SNPRINTF. */ +# if (((!WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR) \ + && (HAVE_SNPRINTF_RETVAL_C99 && HAVE_SNPRINTF_TRUNCATION_C99)) \ || ((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \ && !defined __UCLIBC__) \ || (defined __APPLE__ && defined __MACH__) \ + || defined __OpenBSD__ \ || defined __ANDROID__ \ - || (defined _WIN32 && ! defined __CYGWIN__)) - /* On systems where we know that snprintf's return value - conforms to ISO C 99 (HAVE_SNPRINTF_RETVAL_C99) and that - snprintf always produces NUL-terminated strings - (HAVE_SNPRINTF_TRUNCATION_C99), it is possible to avoid - using %n. And it is desirable to do so, because more and - more platforms no longer support %n, for "security reasons". - In particular, the following platforms: + || (defined _WIN32 && ! defined __CYGWIN__)) \ + || (WIDE_CHAR_VERSION && MUSL_LIBC) + /* We can avoid passing %n and instead rely on SNPRINTF's + return value if + - !WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR, because otherwise, + when WIDE_CHAR_VERSION && DCHAR_IS_TCHAR, + snwprintf()/_snwprintf() (Windows) and swprintf() (Unix) + don't return the needed buffer size, + and + - we're compiling for a system where we know + - that snprintf's return value conforms to ISO C 99 + (HAVE_SNPRINTF_RETVAL_C99) and + - that snprintf always produces NUL-terminated strings + (HAVE_SNPRINTF_TRUNCATION_C99). + And it is desirable to do so, because more and more platforms + no longer support %n, for "security reasons". */ + /* On specific platforms, listed below, we *must* avoid %n. + In the case + !WIDE_CHAR_VERSION && HAVE_SNPRINTF_RETVAL_C99 && !USE_MSVC__SNPRINTF + we can rely on the return value of snprintf instead. Whereas + in the opposite case + WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF + we need to make room based on an estimation, computed by + MAX_ROOM_NEEDED. */ + /* The following platforms forbid %n: - On glibc2 systems from 2004-10-18 or newer, the use of %n in format strings in writable memory may crash the program (if compiled with _FORTIFY_SOURCE=2). - - On Mac OS X 10.13 or newer, the use of %n in format + - On macOS 10.13 or newer, the use of %n in format strings in writable memory by default crashes the program. + - On OpenBSD, since 2021-08-30, the use of %n in format + strings produces an abort (see + , + ). - On Android, starting on 2018-03-07, the use of %n in format strings produces a fatal error (see ). - On these platforms, HAVE_SNPRINTF_RETVAL_C99 and - HAVE_SNPRINTF_TRUNCATION_C99 are 1. We have listed them - explicitly in the condition above, in case of cross- - compilation (just to be sure). */ - /* On native Windows systems (such as mingw), we can avoid using - %n because: + - On native Windows systems (such as mingw) where the OS is + Windows Vista, the use of %n in format strings by default + crashes the program. See + and + + On the first four of these platforms, if !WIDE_CHAR_VERSION, + it is not a big deal to avoid %n, because on these platforms, + HAVE_SNPRINTF_RETVAL_C99 and HAVE_SNPRINTF_TRUNCATION_C99 are + 1. + On native Windows, if !WIDE_CHAR_VERSION, it's not a big deal + either because: - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, snprintf does not write more than the specified number of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes '4', '5', '6' into buf, not '4', '5', '\0'.) - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf allows us to recognize the case of an insufficient - buffer size: it returns -1 in this case. - On native Windows systems (such as mingw) where the OS is - Windows Vista, the use of %n in format strings by default - crashes the program. See - and - - So we should avoid %n in this situation. */ + buffer size: it returns -1 in this case. */ + /* Additionally, in the WIDE_CHAR_VERSION case, we cannot use %n + on musl libc because we would run into an swprintf() bug. + See . */ fbp[1] = '\0'; # else /* AIX <= 5.1, HP-UX, IRIX, OSF/1, Solaris <= 9, BeOS */ fbp[1] = '%'; @@ -5189,6 +6230,102 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, SNPRINTF_BUF (arg); } break; + case TYPE_INT8_T: + { + int8_t arg = a.arg[dp->arg_index].a.a_int8_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT8_T: + { + uint8_t arg = a.arg[dp->arg_index].a.a_uint8_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT16_T: + { + int16_t arg = a.arg[dp->arg_index].a.a_int16_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT16_T: + { + uint16_t arg = a.arg[dp->arg_index].a.a_uint16_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT32_T: + { + int32_t arg = a.arg[dp->arg_index].a.a_int32_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT32_T: + { + uint32_t arg = a.arg[dp->arg_index].a.a_uint32_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT64_T: + { + int64_t arg = a.arg[dp->arg_index].a.a_int64_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT64_T: + { + uint64_t arg = a.arg[dp->arg_index].a.a_uint64_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT_FAST8_T: + { + int_fast8_t arg = a.arg[dp->arg_index].a.a_int_fast8_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT_FAST8_T: + { + uint_fast8_t arg = a.arg[dp->arg_index].a.a_uint_fast8_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT_FAST16_T: + { + int_fast16_t arg = a.arg[dp->arg_index].a.a_int_fast16_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT_FAST16_T: + { + uint_fast16_t arg = a.arg[dp->arg_index].a.a_uint_fast16_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT_FAST32_T: + { + int_fast32_t arg = a.arg[dp->arg_index].a.a_int_fast32_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT_FAST32_T: + { + uint_fast32_t arg = a.arg[dp->arg_index].a.a_uint_fast32_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT_FAST64_T: + { + int_fast64_t arg = a.arg[dp->arg_index].a.a_int_fast64_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT_FAST64_T: + { + uint_fast64_t arg = a.arg[dp->arg_index].a.a_uint_fast64_t; + SNPRINTF_BUF (arg); + } + break; case TYPE_DOUBLE: { double arg = a.arg[dp->arg_index].a.a_double; @@ -5271,12 +6408,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* Look at the snprintf() return value. */ if (retcount < 0) { -# if !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF +# if (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF /* HP-UX 10.20 snprintf() is doubly deficient: It doesn't understand the '%n' directive, *and* it returns -1 (rather than the length that would have been required) when the buffer is too small. + Likewise, in case of + WIDE_CHAR_VERSION && DCHAR_IS_TCHAR, the + functions snwprintf()/_snwprintf() (Windows) + or swprintf() (Unix). But a failure at this point can also come from other reasons than a too small buffer, such as an invalid wide string argument to @@ -5312,7 +6453,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, # endif } else - count = retcount; + { + count = retcount; +# if WIDE_CHAR_VERSION && defined __MINGW32__ + if (count == 0 && dp->conversion == 'c') + /* snwprintf returned 0 instead of 1. But it + wrote a null wide character. */ + count = 1; +# endif + } } } #endif @@ -5370,7 +6519,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } #endif -#if NEED_PRINTF_UNBOUNDED_PRECISION +#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION if (prec_ourselves) { /* Handle the precision. */ @@ -5430,6 +6579,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, count += insert; } +# if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO + else if (precision == 0 + && move == 1 + && prec_ptr[prefix_count] == '0') + { + /* Replace the "0" result with an empty string. */ + count = prefix_count; + } +# endif } #endif @@ -5442,11 +6600,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #if !DCHAR_IS_TCHAR /* Convert from TCHAR_T[] to DCHAR_T[]. */ - if (dp->conversion == 'c' || dp->conversion == 's') + if (dp->conversion == 'c' || dp->conversion == 's' +# if __GLIBC__ >= 2 && !defined __UCLIBC__ + || (flags & FLAG_LOCALIZED) +# endif + ) { - /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING - TYPE_WIDE_STRING. - The result string is not certainly ASCII. */ + /* The result string is not guaranteed to be ASCII. */ const TCHAR_T *tmpsrc; DCHAR_T *tmpdst; size_t tmpdst_len; @@ -5457,6 +6617,56 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, # else tmpsrc = tmp; # endif +# if WIDE_CHAR_VERSION + /* Convert tmpsrc[0..count-1] to a freshly allocated + wide character array. */ + mbstate_t state; + + mbszero (&state); + tmpdst_len = 0; + { + const TCHAR_T *src = tmpsrc; + size_t srclen = count; + + for (; srclen > 0; tmpdst_len++) + { + /* Parse the next multibyte character. */ + size_t ret = mbrtowc (NULL, src, srclen, &state); + if (ret == (size_t)(-2) || ret == (size_t)(-1)) + goto fail_with_EILSEQ; + if (ret == 0) + ret = 1; + src += ret; + srclen -= ret; + } + } + + tmpdst = + (wchar_t *) malloc ((tmpdst_len + 1) * sizeof (wchar_t)); + if (tmpdst == NULL) + goto out_of_memory; + + mbszero (&state); + { + DCHAR_T *destptr = tmpdst; + const TCHAR_T *src = tmpsrc; + size_t srclen = count; + + for (; srclen > 0; destptr++) + { + /* Parse the next multibyte character. */ + size_t ret = mbrtowc (destptr, src, srclen, &state); + if (ret == (size_t)(-2) || ret == (size_t)(-1)) + /* Should already have been caught in the first + loop, above. */ + abort (); + if (ret == 0) + ret = 1; + src += ret; + srclen -= ret; + } + } +# else tmpdst = DCHAR_CONV_FROM_ENCODING (locale_charset (), iconveh_question_mark, @@ -5465,6 +6675,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, NULL, &tmpdst_len); if (tmpdst == NULL) goto fail_with_errno; +# endif ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len), { free (tmpdst); goto out_of_memory; }); DCHAR_CPY (result + length, tmpdst, tmpdst_len); @@ -5531,7 +6742,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* Here count <= allocated - length. */ /* Perform padding. */ -#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION if (pad_ourselves && has_width) { size_t w; @@ -5590,6 +6801,22 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z') || (*pad_ptr >= 'a' && *pad_ptr <= 'z')) pad_ptr = NULL; + else + /* Do the zero-padding after the "0x" or + "0b" prefix, not before. */ + if (p - rp >= 2 + && *rp == '0' + && (((dp->conversion == 'a' + || dp->conversion == 'x') + && rp[1] == 'x') + || ((dp->conversion == 'A' + || dp->conversion == 'X') + && rp[1] == 'X') + || (dp->conversion == 'b' + && rp[1] == 'b') + || (dp->conversion == 'B' + && rp[1] == 'B'))) + pad_ptr += 2; } /* The generated string now extends from rp to p, with the zero padding insertion point being at @@ -5603,7 +6830,22 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, for (; pad > 0; pad--) *p++ = ' '; } - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) + else if ((flags & FLAG_ZERO) && pad_ptr != NULL + /* ISO C says: "For d, i, o, u, x, and X + conversions, if a precision is + specified, the 0 flag is ignored. */ + && !(has_precision + && (dp->conversion == 'd' + || dp->conversion == 'i' + || dp->conversion == 'o' + || dp->conversion == 'u' + || dp->conversion == 'x' + || dp->conversion == 'X' + /* Although ISO C does not + require it, treat 'b' and 'B' + like 'x' and 'X'. */ + || dp->conversion == 'b' + || dp->conversion == 'B'))) { /* Pad with zeroes. */ DCHAR_T *q = end; @@ -5697,7 +6939,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, errno = ENOMEM; goto fail_with_errno; -#if ENABLE_UNISTDIO || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) +#if ENABLE_UNISTDIO || ((!USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) || ((NEED_PRINTF_DIRECTIVE_LC || ENABLE_WCHAR_FALLBACK) && HAVE_WINT_T && !WIDE_CHAR_VERSION) || (NEED_WPRINTF_DIRECTIVE_C && WIDE_CHAR_VERSION) fail_with_EILSEQ: errno = EILSEQ; goto fail_with_errno; diff --git a/gl/vasnprintf.h b/gl/vasnprintf.h index f69649f..7ed9145 100644 --- a/gl/vasnprintf.h +++ b/gl/vasnprintf.h @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -17,6 +17,11 @@ #ifndef _VASNPRINTF_H #define _VASNPRINTF_H +/* This file uses _GL_ATTRIBUTE_FORMAT. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Get va_list. */ #include diff --git a/gl/vasprintf.c b/gl/vasprintf.c index d2878cd..e52aaca 100644 --- a/gl/vasprintf.c +++ b/gl/vasprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2023 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/verify.h b/gl/verify.h index b63cb26..08268c2 100644 --- a/gl/verify.h +++ b/gl/verify.h @@ -1,6 +1,6 @@ /* Compile-time assert-like macros. - Copyright (C) 2005-2006, 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -188,9 +188,9 @@ template _gl_verify_type<(R) ? 1 : -1> #elif defined _GL_HAVE__STATIC_ASSERT # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ - struct { \ - _Static_assert (R, DIAGNOSTIC); \ - int _gl_dummy; \ + struct { \ + _Static_assert (R, DIAGNOSTIC); \ + int _gl_dummy; \ } #else # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ @@ -212,8 +212,8 @@ template #elif defined _GL_HAVE__STATIC_ASSERT # define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC) #else -# define _GL_VERIFY(R, DIAGNOSTIC, ...) \ - extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ +# define _GL_VERIFY(R, DIAGNOSTIC, ...) \ + extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] # if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) # pragma GCC diagnostic ignored "-Wnested-externs" @@ -222,22 +222,43 @@ template /* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ #ifdef _GL_STATIC_ASSERT_H -# if !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert +/* Define _Static_assert if needed. */ +/* With clang ≥ 3.8.0 in C++ mode, _Static_assert already works and accepts + 1 or 2 arguments. We better don't override it, because clang's standard + C++ library uses static_assert inside classes in several places, and our + replacement via _GL_VERIFY does not work in these contexts. */ +# if (defined __cplusplus && defined __clang__ \ + && (4 <= __clang_major__ + (8 <= __clang_minor__))) +# if 5 <= __clang_major__ +/* Avoid "warning: 'static_assert' with no message is a C++17 extension". */ +# pragma clang diagnostic ignored "-Wc++17-extensions" +# else +/* Avoid "warning: static_assert with no message is a C++1z extension". */ +# pragma clang diagnostic ignored "-Wc++1z-extensions" +# endif +# elif !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert # if !defined _MSC_VER || defined __clang__ # define _Static_assert(...) \ _GL_VERIFY (__VA_ARGS__, "static assertion failed", -) # else - /* Work around MSVC preprocessor incompatibility with ISO C; see - . */ -# define _Static_assert(R, ...) \ - _GL_VERIFY ((R), "static assertion failed", -) +# if defined __cplusplus && _MSC_VER >= 1910 + /* In MSVC 14.1 or newer, static_assert accepts one or two arguments, + but _Static_assert is not defined. */ +# define _Static_assert static_assert +# else + /* Work around MSVC preprocessor incompatibility with ISO C; see + . */ +# define _Static_assert(R, ...) \ + _GL_VERIFY ((R), "static assertion failed", -) +# endif # endif # endif +/* Define static_assert if needed. */ # if (!defined static_assert \ && __STDC_VERSION__ < 202311 \ && (!defined __cplusplus \ || (__cpp_static_assert < 201411 \ - && __GNUG__ < 6 && __clang_major__ < 6))) + && __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910))) # if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__ /* MSVC 14 in C++ mode supports the two-arguments static_assert but not the one-argument static_assert, and it does not support _Static_assert. @@ -250,6 +271,8 @@ template # define _GL_SA3 static_assert # define _GL_SA_PICK(x1,x2,x3,x4,...) x4 # define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__) +/* Avoid "fatal error C1189: #error: The C++ Standard Library forbids macroizing keywords." */ +# define _ALLOW_KEYWORD_MACROS 1 # else # define static_assert _Static_assert /* C11 requires this #define. */ # endif @@ -268,14 +291,16 @@ template # define _GL_HAS_BUILTIN_TRAP 0 #endif -#if defined __clang_major__ && __clang_major__ < 5 -# define _GL_HAS_BUILTIN_UNREACHABLE 0 -#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) -# define _GL_HAS_BUILTIN_UNREACHABLE 1 -#elif defined __has_builtin -# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) -#else -# define _GL_HAS_BUILTIN_UNREACHABLE 0 +#ifndef _GL_HAS_BUILTIN_UNREACHABLE +# if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# define _GL_HAS_BUILTIN_UNREACHABLE 1 +# elif defined __has_builtin +# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) +# else +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# endif #endif /* Each of these macros verifies that its argument R is nonzero. To diff --git a/gl/vsnprintf.c b/gl/vsnprintf.c index acd4e2d..e6676a1 100644 --- a/gl/vsnprintf.c +++ b/gl/vsnprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 2004, 2006-2023 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc. Written by Simon Josefsson and Yoann Vandoorselaere . This file is free software: you can redistribute it and/or modify diff --git a/gl/w32sock.h b/gl/w32sock.h index 84e46e3..166a5f7 100644 --- a/gl/w32sock.h +++ b/gl/w32sock.h @@ -1,6 +1,6 @@ /* w32sock.h --- internal auxiliary functions for Windows socket functions - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/warn-on-use.h b/gl/warn-on-use.h index 3075603..701013a 100644 --- a/gl/warn-on-use.h +++ b/gl/warn-on-use.h @@ -1,5 +1,5 @@ /* A C macro for emitting warnings if a function is used. - Copyright (C) 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2010-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -32,6 +32,10 @@ _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' linkage. + _GL_WARN_ON_USE should not be used more than once for a given function + in a given compilation unit (because this may generate a warning even + if the function is never called). + However, one of the reasons that a function is a portability trap is if it has the wrong signature. Declaring FUNCTION with a different signature in C is a compilation error, so this macro must use the diff --git a/gl/wchar.in.h b/gl/wchar.in.h index 09c9185..a33a10f 100644 --- a/gl/wchar.in.h +++ b/gl/wchar.in.h @@ -1,6 +1,6 @@ /* A substitute for ISO C99 , for platforms that have issues. - Copyright (C) 2007-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -84,6 +84,13 @@ #ifndef _@GUARD_PREFIX@_WCHAR_H #define _@GUARD_PREFIX@_WCHAR_H +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers that can be freed by passing them as the Ith argument to the function F. */ @@ -130,6 +137,28 @@ # endif #endif +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ @@ -188,7 +217,11 @@ typedef int rpl_mbstate_t; # if (@REPLACE_FREE@ && !defined free \ && !(defined __cplusplus && defined GNULIB_NAMESPACE)) /* We can't do '#define free rpl_free' here. */ +# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) +_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW; +# else _GL_EXTERN_C void rpl_free (void *); +# endif # undef _GL_ATTRIBUTE_DEALLOC_FREE # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) # else @@ -200,7 +233,7 @@ _GL_EXTERN_C void __cdecl free (void *); # else # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) -_GL_EXTERN_C void free (void *) throw (); +_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; # else _GL_EXTERN_C void free (void *); # endif @@ -215,13 +248,20 @@ _GL_EXTERN_C void __cdecl free (void *); # else # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) -_GL_EXTERN_C void free (void *) throw (); +_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; # else _GL_EXTERN_C void free (void *); # endif # endif #endif + +#if @GNULIB_MBSZERO@ +/* Get memset(). */ +# include +#endif + + /* Convert a single-byte character to a wide character. */ #if @GNULIB_BTOWC@ # if @REPLACE_BTOWC@ @@ -278,7 +318,7 @@ _GL_WARN_ON_USE (wctob, "wctob is unportable - " #endif -/* Test whether *PS is in the initial state. */ +/* Test whether *PS is in an initial state. */ #if @GNULIB_MBSINIT@ # if @REPLACE_MBSINIT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -305,6 +345,208 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - " #endif +/* Put *PS into an initial state. */ +#if @GNULIB_MBSZERO@ +/* ISO C 23 § 7.31.6.(3) says that zeroing an mbstate_t is a way to put the + mbstate_t into an initial state. However, on many platforms an mbstate_t + is large, and it is possible - as an optimization - to get away with zeroing + only part of it. So, instead of + + mbstate_t state = { 0 }; + + or + + mbstate_t state; + memset (&state, 0, sizeof (mbstate_t)); + + we can write this faster code: + + mbstate_t state; + mbszero (&state); + */ +/* _GL_MBSTATE_INIT_SIZE describes how mbsinit() behaves: It is the number of + bytes at the beginning of an mbstate_t that need to be zero, for mbsinit() + to return true. + _GL_MBSTATE_ZERO_SIZE is the number of bytes at the beginning of an mbstate_t + that need to be zero, + - for mbsinit() to return true, and + - for all other multibyte-aware functions to operate properly. + 0 < _GL_MBSTATE_INIT_SIZE <= _GL_MBSTATE_ZERO_SIZE <= sizeof (mbstate_t). + These values are determined by source code inspection, where possible, and + by running the gnulib unit tests. + We need _GL_MBSTATE_INIT_SIZE because if we define _GL_MBSTATE_ZERO_SIZE + without considering what mbsinit() does, we get test failures such as + assertion "mbsinit (&iter->state)" failed + */ +# if GNULIB_defined_mbstate_t /* AIX, IRIX */ +/* mbstate_t has at least 4 bytes. They are used as coded in + gnulib/lib/mbrtowc.c. */ +# define _GL_MBSTATE_INIT_SIZE 1 +/* define _GL_MBSTATE_ZERO_SIZE 4 + does not work: it causes test failures. + So, use the safe fallback value, below. */ +# elif __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 /* glibc */ +/* mbstate_t is defined in . + For more details, see glibc/iconv/skeleton.c. */ +# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (((mbstate_t) {0}).__count) */ +# define _GL_MBSTATE_ZERO_SIZE /* 8 */ sizeof (mbstate_t) +# elif defined MUSL_LIBC /* musl libc */ +/* mbstate_t is defined in . + It is an opaque aligned 8-byte struct, of which at most the first + 4 bytes are used. + For more details, see src/multibyte/mbrtowc.c. */ +# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (unsigned) */ +# define _GL_MBSTATE_ZERO_SIZE 4 +# elif defined __APPLE__ && defined __MACH__ /* macOS */ +/* On macOS, mbstate_t is defined in . + It is an opaque aligned 128-byte struct, of which at most the first + 12 bytes are used. + For more details, see the __mbsinit implementations in + Libc-/locale/FreeBSD/ + {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8,utf2}.c. */ +/* File INIT_SIZE ZERO_SIZE + ascii.c 0 0 + none.c 0 0 + euc.c 12 12 + mskanji.c 4 4 + big5.c 4 4 + gb2312.c 4 6 + gbk.c 4 4 + gb18030.c 4 8 + utf8.c 8 10 + utf2.c 8 12 */ +# define _GL_MBSTATE_INIT_SIZE 12 +# define _GL_MBSTATE_ZERO_SIZE 12 +# elif defined __FreeBSD__ /* FreeBSD */ +/* On FreeBSD, mbstate_t is defined in src/sys/sys/_types.h. + It is an opaque aligned 128-byte struct, of which at most the first + 12 bytes are used. + For more details, see the __mbsinit implementations in + src/lib/libc/locale/ + {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */ +/* File INIT_SIZE ZERO_SIZE + ascii.c 0 0 + none.c 0 0 + euc.c 12 12 + mskanji.c 4 4 + big5.c 4 4 + gb2312.c 4 6 + gbk.c 4 4 + gb18030.c 4 8 + utf8.c 8 12 */ +# define _GL_MBSTATE_INIT_SIZE 12 +# define _GL_MBSTATE_ZERO_SIZE 12 +# elif defined __NetBSD__ /* NetBSD */ +/* On NetBSD, mbstate_t is defined in src/sys/sys/ansi.h. + It is an opaque aligned 128-byte struct, of which at most the first + 28 bytes are used. + For more details, see the *State types in + src/lib/libc/citrus/modules/citrus_*.c + (ignoring citrus_{hz,iso2022,utf7,viqr,zw}.c, since these implement + stateful encodings, not usable as locale encodings). */ +/* File ZERO_SIZE + citrus/citrus_none.c 0 + citrus/modules/citrus_euc.c 8 + citrus/modules/citrus_euctw.c 8 + citrus/modules/citrus_mskanji.c 8 + citrus/modules/citrus_big5.c 8 + citrus/modules/citrus_gbk2k.c 8 + citrus/modules/citrus_dechanyu.c 8 + citrus/modules/citrus_johab.c 6 + citrus/modules/citrus_utf8.c 12 */ +/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test + failures for values < 28. */ +# define _GL_MBSTATE_ZERO_SIZE 28 +# elif defined __OpenBSD__ /* OpenBSD */ +/* On OpenBSD, mbstate_t is defined in src/sys/sys/_types.h. + It is an opaque aligned 128-byte struct, of which at most the first + 12 bytes are used. + For more details, see src/lib/libc/citrus/citrus_*.c. */ +/* File INIT_SIZE ZERO_SIZE + citrus_none.c 0 0 + citrus_utf8.c 12 12 */ +# define _GL_MBSTATE_INIT_SIZE 12 +# define _GL_MBSTATE_ZERO_SIZE 12 +# elif defined __minix /* Minix */ +/* On Minix, mbstate_t is defined in sys/sys/ansi.h. + It is an opaque aligned 128-byte struct. + For more details, see the *State types in + lib/libc/citrus/citrus_*.c. */ +/* File INIT_SIZE ZERO_SIZE + citrus_none.c 0 0 */ +/* But 1 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test + failures for values < 4. */ +# define _GL_MBSTATE_ZERO_SIZE 4 +# elif defined __sun /* Solaris */ +/* On Solaris, mbstate_t is defined in . + It is an opaque aligned 24-byte or 32-byte struct, of which at most the first + 20 or 28 bytes are used. + For more details on OpenSolaris derivatives, see the *State types in + illumos-gate/usr/src/lib/libc/port/locale/ + {none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */ +/* File INIT_SIZE ZERO_SIZE + none.c 0 0 + euc.c 12 12 + mskanji.c 4 4 + big5.c 4 4 + gb2312.c 4 6 + gbk.c 4 4 + gb18030.c 4 8 + utf8.c 12 12 */ +/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test + failures + - in OpenIndiana and OmniOS: for values < 16, + - in Solaris 10 and 11: for values < 20 (in 32-bit mode) + or < 28 (in 64-bit mode). + Since we don't have a good way to distinguish the OpenSolaris derivatives + from the proprietary Solaris versions, and can't inspect the Solaris source + code, use the safe fallback values, below. */ +# elif defined __CYGWIN__ /* Cygwin */ +/* On Cygwin, mbstate_t is defined in . + For more details, see newlib/libc/stdlib/mbtowc_r.c and + winsup/cygwin/strfuncs.cc. */ +# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (int) */ +# define _GL_MBSTATE_ZERO_SIZE 8 +# elif defined _WIN32 && !defined __CYGWIN__ /* Native Windows. */ +/* MSVC defines 'mbstate_t' as an aligned 8-byte struct. + On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined + as an aligned 8-byte struct, of which the first 4 bytes matter. + Use the safe values, below. */ +# elif defined __ANDROID__ /* Android */ +/* Android defines 'mbstate_t' in . + It is an opaque 4-byte or 8-byte struct. + For more details, see + bionic/libc/private/bionic_mbstate.h + bionic/libc/bionic/mbrtoc32.cpp + bionic/libc/bionic/mbrtoc16.cpp + */ +# define _GL_MBSTATE_INIT_SIZE 4 +# define _GL_MBSTATE_ZERO_SIZE 4 +# endif +/* Use safe values as defaults. */ +# ifndef _GL_MBSTATE_INIT_SIZE +# define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t) +# endif +# ifndef _GL_MBSTATE_ZERO_SIZE +# define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t) +# endif +_GL_BEGIN_C_LINKAGE +# if defined IN_MBSZERO +_GL_EXTERN_INLINE +# else +_GL_INLINE +# endif +_GL_ARG_NONNULL ((1)) void +mbszero (mbstate_t *ps) +{ + memset (ps, 0, _GL_MBSTATE_ZERO_SIZE); +} +_GL_END_C_LINKAGE +_GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps)); +_GL_CXXALIASWARN (mbszero); +#endif + + /* Convert a multibyte character to a wide character. */ #if @GNULIB_MBRTOWC@ # if @REPLACE_MBRTOWC@ @@ -441,7 +683,9 @@ _GL_CXXALIAS_SYS (mbsnrtowcs, size_t, const char **restrict srcp, size_t srclen, size_t len, mbstate_t *restrict ps)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (mbsnrtowcs); +# endif #elif defined GNULIB_POSIXCHECK # undef mbsnrtowcs # if HAVE_RAW_DECL_MBSNRTOWCS @@ -629,13 +873,25 @@ _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - " /* Compare N wide characters of S1 and S2. */ #if @GNULIB_WMEMCMP@ -# if !@HAVE_WMEMCMP@ +# if @REPLACE_WMEMCMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wmemcmp +# define wmemcmp rpl_wmemcmp +# endif +_GL_FUNCDECL_RPL (wmemcmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n) + _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wmemcmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n)); +# else +# if !@HAVE_WMEMCMP@ _GL_FUNCDECL_SYS (wmemcmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n) _GL_ATTRIBUTE_PURE); -# endif +# endif _GL_CXXALIAS_SYS (wmemcmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n)); +# endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (wmemcmp); # endif @@ -694,14 +950,27 @@ _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - " /* Copy N wide characters of SRC to DEST. Return pointer to wide characters after the last written wide character. */ #if @GNULIB_WMEMPCPY@ -# if !@HAVE_WMEMPCPY@ +# if @REPLACE_WMEMPCPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wmempcpy +# define wmempcpy rpl_wmempcpy +# endif +_GL_FUNCDECL_RPL (wmempcpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +_GL_CXXALIAS_RPL (wmempcpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +# else +# if !@HAVE_WMEMPCPY@ _GL_FUNCDECL_SYS (wmempcpy, wchar_t *, (wchar_t *restrict dest, const wchar_t *restrict src, size_t n)); -# endif +# endif _GL_CXXALIAS_SYS (wmempcpy, wchar_t *, (wchar_t *restrict dest, const wchar_t *restrict src, size_t n)); +# endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (wmempcpy); # endif @@ -901,11 +1170,21 @@ _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - " /* Compare S1 and S2. */ #if @GNULIB_WCSCMP@ -# if !@HAVE_WCSCMP@ +# if @REPLACE_WCSCMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcscmp +# define wcscmp rpl_wcscmp +# endif +_GL_FUNCDECL_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) + _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); +# else +# if !@HAVE_WCSCMP@ _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) _GL_ATTRIBUTE_PURE); -# endif +# endif _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); +# endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (wcscmp); # endif @@ -920,13 +1199,25 @@ _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - " /* Compare no more than N wide characters of S1 and S2. */ #if @GNULIB_WCSNCMP@ -# if !@HAVE_WCSNCMP@ +# if @REPLACE_WCSNCMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsncmp +# define wcsncmp rpl_wcsncmp +# endif +_GL_FUNCDECL_RPL (wcsncmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n) + _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wcsncmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n)); +# else +# if !@HAVE_WCSNCMP@ _GL_FUNCDECL_SYS (wcsncmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n) _GL_ATTRIBUTE_PURE); -# endif +# endif _GL_CXXALIAS_SYS (wcsncmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n)); +# endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (wcsncmp); # endif @@ -1035,9 +1326,16 @@ _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); namespace, not in the global namespace. So, force a declaration in the global namespace. */ # if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (wcsdup, wchar_t *, + (const wchar_t *s) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); # endif @@ -1045,9 +1343,16 @@ _GL_CXXALIASWARN (wcsdup); #else # if __GNUC__ >= 11 && !defined wcsdup /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s) + _GL_ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (wcsdup, wchar_t *, + (const wchar_t *s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # endif # if defined GNULIB_POSIXCHECK # undef wcsdup @@ -1066,9 +1371,16 @@ _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " # endif _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); # else +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s) + _GL_ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (wcsdup, wchar_t *, + (const wchar_t *s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif # if @HAVE_DECL_WCSDUP@ _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); # endif @@ -1140,7 +1452,7 @@ _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - " #endif -/* Return the length of the initial segmet of WCS which consists entirely +/* Return the length of the initial segment of WCS which consists entirely of wide characters not in REJECT. */ #if @GNULIB_WCSCSPN@ # if !@HAVE_WCSCSPN@ @@ -1160,7 +1472,7 @@ _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - " #endif -/* Return the length of the initial segmet of WCS which consists entirely +/* Return the length of the initial segment of WCS which consists entirely of wide characters in ACCEPT. */ #if @GNULIB_WCSSPN@ # if !@HAVE_WCSSPN@ @@ -1215,12 +1527,25 @@ _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - " /* Find the first occurrence of NEEDLE in HAYSTACK. */ #if @GNULIB_WCSSTR@ -# if !@HAVE_WCSSTR@ +# if @REPLACE_WCSSTR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsstr +# define wcsstr rpl_wcsstr +# endif +_GL_FUNCDECL_RPL (wcsstr, wchar_t *, + (const wchar_t *restrict haystack, + const wchar_t *restrict needle) + _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wcsstr, wchar_t *, + (const wchar_t *restrict haystack, + const wchar_t *restrict needle)); +# else +# if !@HAVE_WCSSTR@ _GL_FUNCDECL_SYS (wcsstr, wchar_t *, (const wchar_t *restrict haystack, const wchar_t *restrict needle) _GL_ATTRIBUTE_PURE); -# endif +# endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *); @@ -1231,6 +1556,7 @@ _GL_CXXALIAS_SYS_CAST2 (wcsstr, (const wchar_t *restrict, const wchar_t *restrict), const wchar_t *, (const wchar_t *restrict, const wchar_t *restrict)); +# endif # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (wcsstr, wchar_t *, @@ -1358,6 +1684,24 @@ _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - " #endif +#if @GNULIB_WGETCWD@ && (defined _WIN32 && !defined __CYGWIN__) +/* Gets the name of the current working directory. + (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters. + This function stores the working directory (NUL-terminated) in BUF and + returns BUF. + (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE + wide characters long, unless SIZE == 0, in which case it is as big as + necessary. + If the directory couldn't be determined or SIZE was too small, this function + returns NULL and sets errno. For a directory of length LEN, SIZE should be + >= LEN + 3 in case (a) or >= LEN + 1 in case (b). + Possible errno values include: + - ERANGE if SIZE is too small. + - ENOMEM if the memory could no be allocated. */ +_GL_FUNCDECL_SYS (wgetcwd, wchar_t *, (wchar_t *buf, size_t size)); +#endif + + #endif /* _@GUARD_PREFIX@_WCHAR_H */ #endif /* _@GUARD_PREFIX@_WCHAR_H */ #endif diff --git a/gl/wcrtomb.c b/gl/wcrtomb.c index 48a6c8e..197b020 100644 --- a/gl/wcrtomb.c +++ b/gl/wcrtomb.c @@ -1,5 +1,5 @@ /* Convert wide character to multibyte character. - Copyright (C) 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2008-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This file is free software: you can redistribute it and/or modify @@ -29,7 +29,7 @@ wcrtomb (char *s, wchar_t wc, mbstate_t *ps) #undef wcrtomb { /* This implementation of wcrtomb supports only stateless encodings. - ps must be in the initial state. */ + ps must be in an initial state. */ if (ps != NULL && !mbsinit (ps)) { errno = EINVAL; diff --git a/gl/wctype-h.c b/gl/wctype-h.c index 7d3e14a..7e4ff13 100644 --- a/gl/wctype-h.c +++ b/gl/wctype-h.c @@ -1,6 +1,6 @@ /* Inline functions for . - Copyright (C) 2012-2023 Free Software Foundation, Inc. + Copyright (C) 2012-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -20,4 +20,4 @@ #include #define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE -#include "wctype.h" +#include diff --git a/gl/wctype-impl.h b/gl/wctype-impl.h new file mode 100644 index 0000000..26d68b4 --- /dev/null +++ b/gl/wctype-impl.h @@ -0,0 +1,96 @@ +/* Get descriptor for a wide character property. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +wctype_t +wctype (const char* name) +{ + switch (name[0]) + { + case 'a': + switch (name[1]) + { + case 'l': + switch (name[2]) + { + case 'n': + if (strcmp (name + 3, "um") == 0) + return (wctype_t) iswalnum; + break; + case 'p': + if (strcmp (name + 3, "ha") == 0) + return (wctype_t) iswalpha; + break; + default: + break; + } + break; + default: + break; + } + break; + case 'b': + if (strcmp (name + 1, "lank") == 0) + return (wctype_t) iswblank; + break; + case 'c': + if (strcmp (name + 1, "ntrl") == 0) + return (wctype_t) iswcntrl; + break; + case 'd': + if (strcmp (name + 1, "igit") == 0) + return (wctype_t) iswdigit; + break; + case 'g': + if (strcmp (name + 1, "raph") == 0) + return (wctype_t) iswgraph; + break; + case 'l': + if (strcmp (name + 1, "ower") == 0) + return (wctype_t) iswlower; + break; + case 'p': + switch (name[1]) + { + case 'r': + if (strcmp (name + 2, "int") == 0) + return (wctype_t) iswprint; + break; + case 'u': + if (strcmp (name + 2, "nct") == 0) + return (wctype_t) iswpunct; + break; + default: + break; + } + break; + case 's': + if (strcmp (name + 1, "pace") == 0) + return (wctype_t) iswspace; + break; + case 'u': + if (strcmp (name + 1, "pper") == 0) + return (wctype_t) iswupper; + break; + case 'x': + if (strcmp (name + 1, "digit") == 0) + return (wctype_t) iswxdigit; + break; + default: + break; + } + return NULL; +} diff --git a/gl/wctype.c b/gl/wctype.c new file mode 100644 index 0000000..914f684 --- /dev/null +++ b/gl/wctype.c @@ -0,0 +1,25 @@ +/* Get descriptor for a wide character property. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +#include "wctype-impl.h" diff --git a/gl/wctype.in.h b/gl/wctype.in.h index f6e474d..851c4f4 100644 --- a/gl/wctype.in.h +++ b/gl/wctype.in.h @@ -1,6 +1,6 @@ /* A substitute for ISO C99 , for platforms that lack it. - Copyright (C) 2006-2023 Free Software Foundation, Inc. + Copyright (C) 2006-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -44,6 +44,12 @@ #ifndef _@GUARD_PREFIX@_WCTYPE_H +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #if @HAVE_WINT_T@ /* Solaris 2.5 has a bug: must be included before . */ # include @@ -68,9 +74,6 @@ #ifndef _@GUARD_PREFIX@_WCTYPE_H #define _@GUARD_PREFIX@_WCTYPE_H -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_WCTYPE_INLINE # define _GL_WCTYPE_INLINE _GL_INLINE @@ -78,6 +81,8 @@ _GL_INLINE_HEADER_BEGIN /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + /* The definition of _GL_WARN_ON_USE is copied here. */ /* Solaris 2.6 includes which includes which @@ -127,7 +132,8 @@ typedef unsigned int rpl_wint_t; /* FreeBSD 4.4 to 4.11 has but lacks the functions. Linux libc5 has and the functions but they are broken. mingw and MSVC have and the functions but they take a wchar_t - as argument, not an rpl_wint_t. + as argument, not an rpl_wint_t. Additionally, the mingw iswprint function + and the Android iswpunct function are broken. Assume all 11 functions (all isw* except iswblank) are implemented the same way, or not at all. */ # if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ @@ -179,7 +185,11 @@ rpl_iswlower (wint_t wc) _GL_WCTYPE_INLINE int rpl_iswprint (wint_t wc) { +# ifdef __MINGW32__ + return ((wchar_t) wc == wc ? wc == ' ' || iswgraph ((wchar_t) wc) : 0); +# else return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0); +# endif } _GL_WCTYPE_INLINE int @@ -484,6 +494,16 @@ _GL_FUNCDECL_RPL (iswdigit, int, (wint_t wc)); # endif # endif +# if @GNULIB_ISWPUNCT@ +# if @REPLACE_ISWPUNCT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef iswpunct +# define iswpunct rpl_iswpunct +# endif +_GL_FUNCDECL_RPL (iswpunct, int, (wint_t wc)); +# endif +# endif + # if @GNULIB_ISWXDIGIT@ # if @REPLACE_ISWXDIGIT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -623,14 +643,32 @@ _GL_CXXALIASWARN (iswblank); typedef void * wctype_t; # define GNULIB_defined_wctype_t 1 # endif +#elif @REPLACE_WCTYPE@ +# if !GNULIB_defined_wctype_t +typedef void *rpl_wctype_t; +# undef wctype_t +# define wctype_t rpl_wctype_t +# define GNULIB_defined_wctype_t 1 +# endif #endif /* Get a descriptor for a wide character property. */ #if @GNULIB_WCTYPE@ -# if !@HAVE_WCTYPE_T@ -_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)); -# endif +# if @REPLACE_WCTYPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wctype +# define wctype rpl_wctype +# endif +_GL_FUNCDECL_RPL (wctype, wctype_t, (const char *name) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (wctype, wctype_t, (const char *name)); +# else +# if !@HAVE_WCTYPE_T@ +_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name) + _GL_ARG_NONNULL ((1))); +# endif _GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); +# endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (wctype); # endif @@ -646,7 +684,7 @@ _GL_WARN_ON_USE (wctype, "wctype is unportable - " The argument WC must be either a wchar_t value or WEOF. The argument DESC must have been returned by the wctype() function. */ #if @GNULIB_ISWCTYPE@ -# if @GNULIBHEADERS_OVERRIDE_WINT_T@ +# if @GNULIBHEADERS_OVERRIDE_WINT_T@ || @REPLACE_WCTYPE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef iswctype # define iswctype rpl_iswctype @@ -687,14 +725,32 @@ _GL_CXXALIASWARN (towupper); typedef void * wctrans_t; # define GNULIB_defined_wctrans_t 1 # endif +#elif @REPLACE_WCTRANS@ +# if !GNULIB_defined_wctrans_t +typedef void *rpl_wctrans_t; +# undef wctrans_t +# define wctrans_t rpl_wctrans_t +# define GNULIB_defined_wctrans_t 1 +# endif #endif /* Get a descriptor for a wide character case conversion. */ #if @GNULIB_WCTRANS@ -# if !@HAVE_WCTRANS_T@ -_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name)); -# endif +# if @REPLACE_WCTRANS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wctrans +# define wctrans rpl_wctrans +# endif +_GL_FUNCDECL_RPL (wctrans, wctrans_t, (const char *name) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (wctrans, wctrans_t, (const char *name)); +# else +# if !@HAVE_WCTRANS_T@ +_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name) + _GL_ARG_NONNULL ((1))); +# endif _GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name)); +# endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (wctrans); # endif @@ -710,10 +766,19 @@ _GL_WARN_ON_USE (wctrans, "wctrans is unportable - " The argument WC must be either a wchar_t value or WEOF. The argument DESC must have been returned by the wctrans() function. */ #if @GNULIB_TOWCTRANS@ -# if !@HAVE_WCTRANS_T@ +# if @REPLACE_WCTRANS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef towctrans +# define towctrans rpl_towctrans +# endif +_GL_FUNCDECL_RPL (towctrans, wint_t, (wint_t wc, wctrans_t desc)); +_GL_CXXALIAS_RPL (towctrans, wint_t, (wint_t wc, wctrans_t desc)); +# else +# if !@HAVE_WCTRANS_T@ _GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); -# endif +# endif _GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); +# endif # if __GLIBC__ >= 2 _GL_CXXALIASWARN (towctrans); # endif diff --git a/gl/windows-initguard.h b/gl/windows-initguard.h index 9d36f53..6bace3f 100644 --- a/gl/windows-initguard.h +++ b/gl/windows-initguard.h @@ -1,5 +1,5 @@ /* Init guards, somewhat like spinlocks (native Windows implementation). - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/windows-mutex.c b/gl/windows-mutex.c index ab7258c..b112e13 100644 --- a/gl/windows-mutex.c +++ b/gl/windows-mutex.c @@ -1,5 +1,5 @@ /* Plain mutexes (native Windows implementation). - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/windows-mutex.h b/gl/windows-mutex.h index 039eb70..88de4bd 100644 --- a/gl/windows-mutex.h +++ b/gl/windows-mutex.h @@ -1,5 +1,5 @@ /* Plain mutexes (native Windows implementation). - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/windows-once.c b/gl/windows-once.c index 0d28281..17854f5 100644 --- a/gl/windows-once.c +++ b/gl/windows-once.c @@ -1,5 +1,5 @@ /* Once-only control (native Windows implementation). - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/windows-once.h b/gl/windows-once.h index 5488568..c5bbcd5 100644 --- a/gl/windows-once.h +++ b/gl/windows-once.h @@ -1,5 +1,5 @@ /* Once-only control (native Windows implementation). - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/windows-recmutex.c b/gl/windows-recmutex.c index a8ce9a0..e5672ba 100644 --- a/gl/windows-recmutex.c +++ b/gl/windows-recmutex.c @@ -1,5 +1,5 @@ /* Plain recursive mutexes (native Windows implementation). - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/windows-recmutex.h b/gl/windows-recmutex.h index 08ff459..9fa445b 100644 --- a/gl/windows-recmutex.h +++ b/gl/windows-recmutex.h @@ -1,5 +1,5 @@ /* Plain recursive mutexes (native Windows implementation). - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/windows-rwlock.c b/gl/windows-rwlock.c index 7cbd7bb..e60c4ef 100644 --- a/gl/windows-rwlock.c +++ b/gl/windows-rwlock.c @@ -1,5 +1,5 @@ /* Read-write locks (native Windows implementation). - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/windows-rwlock.h b/gl/windows-rwlock.h index fe8381e..08d6775 100644 --- a/gl/windows-rwlock.h +++ b/gl/windows-rwlock.h @@ -1,5 +1,5 @@ /* Read-write locks (native Windows implementation). - Copyright (C) 2005-2023 Free Software Foundation, Inc. + Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/xalloc-die.c b/gl/xalloc-die.c index 7605eee..c053c7a 100644 --- a/gl/xalloc-die.c +++ b/gl/xalloc-die.c @@ -1,6 +1,6 @@ /* Report a memory allocation failure and exit. - Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2023 Free Software + Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ #include -#include "error.h" +#include #include "exitfail.h" #include "gettext.h" diff --git a/gl/xalloc-oversized.h b/gl/xalloc-oversized.h index 5dbdfb5..7f30f83 100644 --- a/gl/xalloc-oversized.h +++ b/gl/xalloc-oversized.h @@ -1,6 +1,6 @@ /* xalloc-oversized.h -- memory allocation size checking - Copyright (C) 1990-2000, 2003-2004, 2006-2023 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2003-2004, 2006-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -29,8 +29,7 @@ is SIZE_MAX - 1. */ #define __xalloc_oversized(n, s) \ ((s) != 0 \ - && ((size_t) (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) \ - < (n))) + && (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) < (n)) /* Return 1 if and only if an array of N objects, each of size S, cannot exist reliably because its total size in bytes would exceed @@ -48,13 +47,13 @@ #if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX # define xalloc_oversized(n, s) \ __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1) -#elif (5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ \ - && PTRDIFF_MAX < SIZE_MAX) +#elif 5 <= __GNUC__ && !defined __ICC && PTRDIFF_MAX < SIZE_MAX # define xalloc_oversized(n, s) \ (__builtin_constant_p (n) && __builtin_constant_p (s) \ ? __xalloc_oversized (n, s) \ - : ({ ptrdiff_t __xalloc_count; \ - __builtin_mul_overflow (n, s, &__xalloc_count); })) + : __extension__ \ + ({ ptrdiff_t __xalloc_count; \ + __builtin_mul_overflow (n, s, &__xalloc_count); })) /* Other compilers use integer division; this may be slower but is more portable. */ diff --git a/gl/xalloc.h b/gl/xalloc.h index f373c2f..75a5db3 100644 --- a/gl/xalloc.h +++ b/gl/xalloc.h @@ -1,6 +1,6 @@ /* xalloc.h -- malloc with out-of-memory checking - Copyright (C) 1990-2000, 2003-2004, 2006-2023 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2003-2004, 2006-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,13 @@ #ifndef XALLOC_H_ #define XALLOC_H_ +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _Noreturn, + _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_RETURNS_NONNULL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + #include #include @@ -25,9 +32,6 @@ # include "idx.h" #endif -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef XALLOC_INLINE # define XALLOC_INLINE _GL_INLINE @@ -46,7 +50,7 @@ extern "C" { or by using gnulib's xalloc-die module. This is the function to call when one wants the program to die because of a memory allocation failure. */ -/*extern*/ _Noreturn void xalloc_die (void); +_Noreturn void xalloc_die (void); #endif /* GNULIB_XALLOC_DIE */ diff --git a/gl/xmalloc.c b/gl/xmalloc.c index 289cbd0..5befdab 100644 --- a/gl/xmalloc.c +++ b/gl/xmalloc.c @@ -1,6 +1,6 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990-2000, 2002-2006, 2008-2023 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2002-2006, 2008-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ #include static void * _GL_ATTRIBUTE_PURE -nonnull (void *p) +check_nonnull (void *p) { if (!p) xalloc_die (); @@ -42,13 +42,13 @@ nonnull (void *p) void * xmalloc (size_t s) { - return nonnull (malloc (s)); + return check_nonnull (malloc (s)); } void * ximalloc (idx_t s) { - return nonnull (imalloc (s)); + return check_nonnull (imalloc (s)); } char * @@ -72,7 +72,7 @@ xrealloc (void *p, size_t s) void * xirealloc (void *p, idx_t s) { - return nonnull (irealloc (p, s)); + return check_nonnull (irealloc (p, s)); } /* Change the size of an allocated block of memory P to an array of N @@ -90,7 +90,7 @@ xreallocarray (void *p, size_t n, size_t s) void * xireallocarray (void *p, idx_t n, idx_t s) { - return nonnull (ireallocarray (p, n, s)); + return check_nonnull (ireallocarray (p, n, s)); } /* Allocate an array of N objects, each with S bytes of memory, @@ -295,13 +295,13 @@ xizalloc (idx_t s) void * xcalloc (size_t n, size_t s) { - return nonnull (calloc (n, s)); + return check_nonnull (calloc (n, s)); } void * xicalloc (idx_t n, idx_t s) { - return nonnull (icalloc (n, s)); + return check_nonnull (icalloc (n, s)); } /* Clone an object P of size S, with error checking. There's no need diff --git a/gl/xsize.c b/gl/xsize.c index 279ae82..8774467 100644 --- a/gl/xsize.c +++ b/gl/xsize.c @@ -1,6 +1,6 @@ /* Checked size_t computations. - Copyright (C) 2012-2023 Free Software Foundation, Inc. + Copyright (C) 2012-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/gl/xsize.h b/gl/xsize.h index 1ec78e7..619c0ed 100644 --- a/gl/xsize.h +++ b/gl/xsize.h @@ -1,6 +1,6 @@ /* xsize.h -- Checked size_t computations. - Copyright (C) 2003, 2008-2023 Free Software Foundation, Inc. + Copyright (C) 2003, 2008-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,6 +18,11 @@ #ifndef _XSIZE_H #define _XSIZE_H +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, HAVE_STDINT_H. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Get size_t. */ #include @@ -30,14 +35,16 @@ /* Get ATTRIBUTE_PURE. */ #include "attribute.h" -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif _GL_INLINE_HEADER_BEGIN #ifndef XSIZE_INLINE # define XSIZE_INLINE _GL_INLINE #endif +#ifdef __cplusplus +extern "C" { +#endif + + /* The size of memory objects is often computed through expressions of type size_t. Example: void* p = malloc (header_size + n * element_size). @@ -103,6 +110,11 @@ xmax (size_t size1, size_t size2) #define size_in_bounds_p(SIZE) \ ((SIZE) != SIZE_MAX) + +#ifdef __cplusplus +} +#endif + _GL_INLINE_HEADER_END #endif /* _XSIZE_H */ -- cgit v0.10-9-g596f